mirror of
git://gcc.gnu.org/git/gcc.git
synced 2025-03-26 11:21:37 +08:00
Mark switch expression as used to avoid bogus warning
PR c/88660 * c-parser.c (c_parser_switch_statement): Make sure to request marking the switch expr as used. PR c/88660 * gcc.dg/pr88660.c: New test.
This commit is contained in:
parent
5fb07870fa
commit
f9eb0973ed
@ -1,3 +1,9 @@
|
||||
2020-01-30 Jeff Law <law@redhat.com>
|
||||
|
||||
PR c/88660
|
||||
* c-parser.c (c_parser_switch_statement): Make sure to request
|
||||
marking the switch expr as used.
|
||||
|
||||
2020-01-22 Joseph Myers <joseph@codesourcery.com>
|
||||
|
||||
PR c/93348
|
||||
|
@ -6607,7 +6607,7 @@ c_parser_switch_statement (c_parser *parser, bool *if_p)
|
||||
&& c_token_starts_typename (c_parser_peek_2nd_token (parser)))
|
||||
explicit_cast_p = true;
|
||||
ce = c_parser_expression (parser);
|
||||
ce = convert_lvalue_to_rvalue (switch_cond_loc, ce, true, false);
|
||||
ce = convert_lvalue_to_rvalue (switch_cond_loc, ce, true, true);
|
||||
expr = ce.value;
|
||||
/* ??? expr has no valid location? */
|
||||
parens.skip_until_found_close (parser);
|
||||
|
@ -1,3 +1,8 @@
|
||||
2020-01-30 Jeff Law <law@redhat.com
|
||||
|
||||
PR c/88660
|
||||
* gcc.dg/pr88660.c: New test
|
||||
|
||||
2020-01-30 Jakub Jelinek <jakub@redhat.com>
|
||||
|
||||
PR lto/93384
|
||||
|
13
gcc/testsuite/gcc.dg/pr88660.c
Normal file
13
gcc/testsuite/gcc.dg/pr88660.c
Normal file
@ -0,0 +1,13 @@
|
||||
/* { dg-do-compile } */
|
||||
/* { dg-options "-O -Wunused-but-set-variable" } */
|
||||
|
||||
int main(void)
|
||||
{
|
||||
const int i = 0;
|
||||
switch(i)
|
||||
{
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user