This is the mail archive of the gcc-bugs@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]

Re: c++/9712: [3.4 regression][New parser] __PRETTY_FUNCTION__ infunction try block causes ICE


http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=9712

This bug is apparently not a "New parser" bug.  It disappears if I
revert the following hunks from a series of patches applied by Jason in
early January:

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.

The segfault happens in finish_fname_decls when it's looking for a
COMPOUND_STMT that isn't there.

Greetz
Steven

Index: c-common.c
===================================================================
RCS file: /cvsroot/gcc/gcc/gcc/c-common.c,v
retrieving revision 1.394
retrieving revision 1.395
diff -c -3 -p -r1.394 -r1.395
*** c-common.c	16 Dec 2002 18:19:00 -0000	1.394
--- c-common.c	3 Jan 2003 19:29:47 -0000	1.395
*************** finish_fname_decls ()
*** 1050,1062 ****
    
    if (body)
      {
!       /* They were called into existence, so add to statement tree.  */
!       body = chainon (body,
! 		      TREE_CHAIN (DECL_SAVED_TREE (current_function_decl)));
!       body = build_stmt (COMPOUND_STMT, body);
!       
!       COMPOUND_STMT_NO_SCOPE (body) = 1;
!       TREE_CHAIN (DECL_SAVED_TREE (current_function_decl)) = body;
      }
    
    for (ix = 0; fname_vars[ix].decl; ix++)
--- 1050,1067 ----
    
    if (body)
      {
!       /* 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);
!       p = &COMPOUND_BODY (*p);
!       if (TREE_CODE (*p) == SCOPE_STMT)
! 	p = &TREE_CHAIN (*p);
! 
!       body = chainon (body, *p);
!       *p = body;
      }
    
    for (ix = 0; fname_vars[ix].decl; ix++)
Index: decl.c
===================================================================
RCS file: /cvsroot/gcc/gcc/gcc/cp/decl.c,v
retrieving revision 1.978
retrieving revision 1.980
diff -c -3 -p -r1.978 -r1.980
*** cp/decl.c	1 Jan 2003 03:16:14 -0000	1.978
--- cp/decl.c	3 Jan 2003 19:48:53 -0000	1.980
*************** cp_make_fname_decl (id, type_dep)
*** 6656,6662 ****
    tree init = cp_fname_init (name);
    tree decl = build_decl (VAR_DECL, id, TREE_TYPE (init));
  
!   /* As we don't push the decl here, we must set the context.  */
    DECL_CONTEXT (decl) = current_function_decl;
    DECL_PRETTY_FUNCTION_P (decl) = type_dep;
        
--- 6656,6662 ----
    tree init = cp_fname_init (name);
    tree decl = build_decl (VAR_DECL, id, TREE_TYPE (init));
  
!   /* As we're using pushdecl_with_scope, we must set the context.  */
    DECL_CONTEXT (decl) = current_function_decl;
    DECL_PRETTY_FUNCTION_P (decl) = type_dep;
        
*************** cp_make_fname_decl (id, type_dep)
*** 6667,6672 ****
--- 6667,6680 ----
    
    TREE_USED (decl) = 1;
  
+   if (current_function_decl)
+     {
+       struct cp_binding_level *b = current_binding_level;
+       while (b->level_chain->parm_flag == 0)
+ 	b = b->level_chain;
+       pushdecl_with_scope (decl, b);
+     }	
+ 
    cp_finish_decl (decl, init, NULL_TREE, LOOKUP_ONLYCONVERTING);
        
    return decl;

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