]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR middle-end/21728 (Nonlocal goto from an unused nested function)
authorRichard Henderson <rth@redhat.com>
Fri, 5 Aug 2005 23:01:54 +0000 (16:01 -0700)
committerRichard Henderson <rth@gcc.gnu.org>
Fri, 5 Aug 2005 23:01:54 +0000 (16:01 -0700)
        PR 21728
        * tree-cfg.c (remove_bb): Transmute DECL_NONLOCAL labels into
        FORCED_LABEL labels.

From-SVN: r102786

gcc/ChangeLog
gcc/testsuite/gcc.c-torture/compile/pr21728.c [new file with mode: 0644]
gcc/tree-cfg.c

index 95076b929428ca1e88473984cb5530999af73c02..3a9b189c9de8d48125696a31cce28911a5183356 100644 (file)
@@ -1,3 +1,9 @@
+2005-08-05  Richard Henderson  <rth@redhat.com>
+
+       PR 21728
+       * tree-cfg.c (remove_bb): Transmute DECL_NONLOCAL labels into
+       FORCED_LABEL labels.
+
 2005-08-05  J"orn Rennecke <joern.rennecke@st.com>
 
        PR middle-end/23135
diff --git a/gcc/testsuite/gcc.c-torture/compile/pr21728.c b/gcc/testsuite/gcc.c-torture/compile/pr21728.c
new file mode 100644 (file)
index 0000000..991cb38
--- /dev/null
@@ -0,0 +1,10 @@
+int main (void)
+{
+  __label__ l1;
+  void __attribute__((used)) q(void)
+  {
+    goto l1;
+  }
+
+  l1:;
+}
index b5a0696ddecc07d1f8baf00dfc05a6cefad9a68a..70dca21bc83aadd63d41ec9508502693f7d0278c 100644 (file)
@@ -1983,11 +1983,23 @@ remove_bb (basic_block bb)
     {
       tree stmt = bsi_stmt (i);
       if (TREE_CODE (stmt) == LABEL_EXPR
-          && FORCED_LABEL (LABEL_EXPR_LABEL (stmt)))
+          && (FORCED_LABEL (LABEL_EXPR_LABEL (stmt))
+             || DECL_NONLOCAL (LABEL_EXPR_LABEL (stmt))))
        {
-         basic_block new_bb = bb->prev_bb;
-         block_stmt_iterator new_bsi = bsi_start (new_bb);
+         basic_block new_bb;
+         block_stmt_iterator new_bsi;
+
+         /* A non-reachable non-local label may still be referenced.
+            But it no longer needs to carry the extra semantics of
+            non-locality.  */
+         if (DECL_NONLOCAL (LABEL_EXPR_LABEL (stmt)))
+           {
+             DECL_NONLOCAL (LABEL_EXPR_LABEL (stmt)) = 0;
+             FORCED_LABEL (LABEL_EXPR_LABEL (stmt)) = 1;
+           }
                  
+         new_bb = bb->prev_bb;
+         new_bsi = bsi_start (new_bb);
          bsi_remove (&i);
          bsi_insert_before (&new_bsi, stmt, BSI_NEW_STMT);
        }