* gimplify.c (gimplify_switch_expr): Look into the innermost lexical
scope.
* c-c++-common/Wswitch-unreachable-2.c: New test.
upstream hash:
6ef0143d8a1ce423db0ae0da55760b4fb82f3bdf
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@236649
138bc75d-0d04-0410-961f-
82ee72b054a4
Change-Id: I1270c2aea4e4561f72a9801607bcdfc5edab9a03
&& 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)
--- /dev/null
+/* 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;
+}