This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
fix 21728
- From: Richard Henderson <rth at redhat dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Fri, 5 Aug 2005 16:03:54 -0700
- Subject: fix 21728
We already have provisions for how to deal with labels that we can't
delete. All that's required for this PR is that we make use of them.
r~
* tree-cfg.c (remove_bb): Transmute DECL_NONLOCAL labels into
FORCED_LABEL labels.
Index: gcc/tree-cfg.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-cfg.c,v
retrieving revision 2.214
diff -u -p -d -r2.214 tree-cfg.c
--- gcc/tree-cfg.c 4 Aug 2005 18:16:27 -0000 2.214
+++ gcc/tree-cfg.c 5 Aug 2005 23:00:27 -0000
@@ -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);
}
Index: gcc/testsuite/gcc.c-torture/compile/pr21728.c
===================================================================
RCS file: gcc/testsuite/gcc.c-torture/compile/pr21728.c
diff -N gcc/testsuite/gcc.c-torture/compile/pr21728.c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gcc/testsuite/gcc.c-torture/compile/pr21728.c 5 Aug 2005 23:00:27 -0000
@@ -0,0 +1,10 @@
+int main (void)
+{
+ __label__ l1;
+ void __attribute__((used)) q(void)
+ {
+ goto l1;
+ }
+
+ l1:;
+}