C identifier lookup speedups, 2/2

Mark Mitchell mark@codesourcery.com
Tue Apr 15 16:36:00 GMT 2003


On Mon, 2003-04-14 at 14:45, Kazu Hirata wrote:
> Hi Zack,
> 
> I digged a tiny bit further.
> 
> While compiling
> 
> struct r {
>   int dummy;
> };
> 
> void
> foo ()
> {
>   strlen (0);
>   struct r hello;
> }
> 
> with h8300-hms-gcc -mh -g, cc1 crashes
> 
> test.c:13: internal compiler error: in lhd_set_decl_assembler_name, at langhooks.c:186
> Please submit a full bug report,
> with preprocessed source if appropriate.
> See <URL:http://gcc.gnu.org/bugs.html> for instructions.

I fixed that with the attached patch, tested with a cross compiler for
your test case and a full build/test on i686-pc-linux-gnu.

Applied on the mainline.

-- 
Mark Mitchell
CodeSourcery, LLC
mark@codesourcery.com
-------------- next part --------------
2003-04-15  Mark Mitchell  <mark@codesourcery.com>

	* c-decl.c (implicitly_declare): Copy declarations that are going
	to be placed in a local scope.

Index: gcc/c-decl.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/c-decl.c,v
retrieving revision 1.379
diff -c -5 -p -r1.379 c-decl.c
*** gcc/c-decl.c	15 Apr 2003 01:37:00 -0000	1.379
--- gcc/c-decl.c	15 Apr 2003 16:17:53 -0000
*************** implicitly_declare (functionid)
*** 1870,1880 ****
  	  implicit_decl_warning (DECL_NAME (decl));
  	  if (DECL_CONTEXT (decl))
  	    warning_with_decl (decl, "previous declaration of `%s'");
  	  C_DECL_IMPLICIT (decl) = 1;
  	}
!       return pushdecl (decl);
      }
  
    /* Not seen before.  */
    decl = build_decl (FUNCTION_DECL, functionid, default_function_type);
    DECL_EXTERNAL (decl) = 1;
--- 1870,1886 ----
  	  implicit_decl_warning (DECL_NAME (decl));
  	  if (DECL_CONTEXT (decl))
  	    warning_with_decl (decl, "previous declaration of `%s'");
  	  C_DECL_IMPLICIT (decl) = 1;
  	}
!       /* If this function is global, then it must already be in the
! 	 global binding level, so there's no need to push it again.  */
!       if (current_binding_level == global_binding_level)
! 	return decl;
!       /* If this is a local declaration, make a copy; we can't have
! 	 the same DECL listed in two different binding levels.  */
!       return pushdecl (copy_node (decl));
      }
  
    /* Not seen before.  */
    decl = build_decl (FUNCTION_DECL, functionid, default_function_type);
    DECL_EXTERNAL (decl) = 1;


More information about the Gcc-patches mailing list