Hi!

As can be seen on the following (IMNSHO valid) testcase, we need to walk
ops of GIMPLE_GOTO, except when it has (non-local) LABEL_DECL in it.
There is code to do this, but it was setting *handled_ops_p to true and
thus not actually walking those (therefore tweaks of wi->* were useless).

Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux, ok for
trunk?

2016-06-10  Jakub Jelinek  <ja...@redhat.com>

        PR middle-end/71494
        * tree-nested.c (convert_nonlocal_reference_stmt): For GIMPLE_GOTO
        without LABEL_DECL, set *handled_ops_p to false instead of true.

        * gcc.c-torture/execute/pr71494.c: New test.

--- gcc/tree-nested.c.jj        2016-04-22 18:21:54.000000000 +0200
+++ gcc/tree-nested.c   2016-06-10 13:29:24.227858894 +0200
@@ -1332,7 +1332,7 @@ convert_nonlocal_reference_stmt (gimple_
        {
          wi->val_only = true;
          wi->is_lhs = false;
-         *handled_ops_p = true;
+         *handled_ops_p = false;
          return NULL_TREE;
        }
       break;
--- gcc/testsuite/gcc.c-torture/execute/pr71494.c.jj    2016-06-10 
13:33:04.776955077 +0200
+++ gcc/testsuite/gcc.c-torture/execute/pr71494.c       2016-06-10 
13:32:43.000000000 +0200
@@ -0,0 +1,22 @@
+/* PR middle-end/71494 */
+
+int
+main ()
+{
+  void *label = &&out;
+  int i = 0;
+  void test (void)
+  {
+    label = &&out2;
+    goto *label;
+   out2:;
+    i++;
+  }
+  goto *label;
+ out:
+  i += 2;
+  test ();
+  if (i != 3)
+    __builtin_abort ();
+  return 0;
+}

        Jakub

Reply via email to