summaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJeff Law <law@redhat.com>2020-01-30 14:09:41 -0700
committerJeff Law <law@redhat.com>2020-01-30 14:09:41 -0700
commitf9eb0973edb2b4eed4cdbba7105b8af7afe5b547 (patch)
tree3f1610ca774902de4f92cdb9152a8f1ea944fb04 /gcc
parent5fb07870fa4c86f529930bae76689ed5bdfcb192 (diff)
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.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/c/ChangeLog6
-rw-r--r--gcc/c/c-parser.c2
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gcc.dg/pr88660.c13
4 files changed, 25 insertions, 1 deletions
diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog
index 9497365a569..995f315a803 100644
--- a/gcc/c/ChangeLog
+++ b/gcc/c/ChangeLog
@@ -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
diff --git a/gcc/c/c-parser.c b/gcc/c/c-parser.c
index 6164017de02..1e8f2f7108d 100644
--- a/gcc/c/c-parser.c
+++ b/gcc/c/c-parser.c
@@ -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);
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 4503016a73e..90eb0b2ffba 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -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
diff --git a/gcc/testsuite/gcc.dg/pr88660.c b/gcc/testsuite/gcc.dg/pr88660.c
new file mode 100644
index 00000000000..09a2d3270bd
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr88660.c
@@ -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;
+ }
+}
+
+