This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Fix PR C++/12709 ICE with __FUNCTION__ and function-try-block


The problem was that this change:

2003-01-02 Jason Merrill <jason@redhat.com>

        * c-common.c (finish_fname_decls): Put the DECL_STMTs inside the
        outermost scope.
        * c-decl.c (c_make_fname_decl): Push the decls there, too.
cp/
        * decl.c (cp_make_fname_decl): Push the decls inside the
        outermost scope.

Really only this part:

! /* They were called into existence, so add to statement tree. Add
! the DECL_STMTs inside the outermost scope. */
! tree *p = &DECL_SAVED_TREE (current_function_decl);
! /* Skip the dummy EXPR_STMT and any EH_SPEC_BLOCK. */
! while (TREE_CODE (*p) != COMPOUND_STMT)
! p = &TREE_CHAIN (*p);


Causes a regression, even tough Jason was trying to fix a bug.
The problem is that TRY_BLOCK is the that is there for this testcase and its body
is not chained on but is the first operand.


This patch fixes that regression.

OK, bootstrapped on powerpc-apple-darwin7.2 with no regressions?

Thanks,
Andrew Pinski


ChangeLog:


	* c-common.c (finish_fname_decls): Use the chain only if the tree is an
	expr_stmt.

Patch:
Index: c-common.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/c-common.c,v
retrieving revision 1.472
diff -u -p -r1.472 c-common.c
--- c-common.c	25 Dec 2003 16:21:34 -0000	1.472
+++ c-common.c	29 Dec 2003 08:15:49 -0000
@@ -1053,7 +1053,13 @@ finish_fname_decls (void)
       tree *p = &DECL_SAVED_TREE (current_function_decl);
       /* Skip the dummy EXPR_STMT and any EH_SPEC_BLOCK.  */
       while (TREE_CODE (*p) != COMPOUND_STMT)
-	p = &TREE_CHAIN (*p);
+        {
+          if (TREE_CODE (*p) == EXPR_STMT)
+            p = &TREE_CHAIN (*p);
+          else
+            p = &TREE_OPERAND(*p, 0);
+        }
+
       p = &COMPOUND_BODY (*p);
       if (TREE_CODE (*p) == SCOPE_STMT)
 	p = &TREE_CHAIN (*p);


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]