aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog6
-rw-r--r--gcc/gimplify.c5
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/c-c++-common/Wswitch-unreachable-2.c18
4 files changed, 32 insertions, 2 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 1b81d41..2b20cc8 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,9 @@
+2016-05-24 Marek Polacek <polacek@redhat.com>
+
+ PR c/71249
+ * gimplify.c (gimplify_switch_expr): Look into the innermost lexical
+ scope.
+
2016-05-24 Jakub Jelinek <jakub@redhat.com>
PR c++/71257
diff --git a/gcc/gimplify.c b/gcc/gimplify.c
index e702bc4..67394e3 100644
--- a/gcc/gimplify.c
+++ b/gcc/gimplify.c
@@ -1605,8 +1605,9 @@ gimplify_switch_expr (tree *expr_p, gimple_seq *pre_p)
&& switch_body_seq != NULL)
{
gimple_seq seq = switch_body_seq;
- if (gimple_code (switch_body_seq) == GIMPLE_BIND)
- seq = gimple_bind_body (as_a <gbind *> (switch_body_seq));
+ /* Look into the innermost lexical scope. */
+ while (gimple_code (seq) == GIMPLE_BIND)
+ seq = gimple_bind_body (as_a <gbind *> (seq));
gimple *stmt = gimple_seq_first_stmt (seq);
enum gimple_code code = gimple_code (stmt);
if (code != GIMPLE_LABEL && code != GIMPLE_TRY)
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index c0a271c..e2b2466 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2016-05-24 Marek Polacek <polacek@redhat.com>
+
+ PR c/71249
+ * c-c++-common/Wswitch-unreachable-2.c: New test.
+
2016-05-24 Jakub Jelinek <jakub@redhat.com>
PR c++/71257
diff --git a/gcc/testsuite/c-c++-common/Wswitch-unreachable-2.c b/gcc/testsuite/c-c++-common/Wswitch-unreachable-2.c
new file mode 100644
index 0000000..8f57392
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/Wswitch-unreachable-2.c
@@ -0,0 +1,18 @@
+/* PR c/71249 */
+/* { dg-do compile } */
+
+int
+f (int i)
+{
+ switch (i)
+ {
+ {
+ int j;
+ foo:
+ return i; /* { dg-bogus "statement will never be executed" } */
+ };
+ case 3:
+ goto foo;
+ }
+ return i;
+}