(C++) patch for retrofit_lang_decl

Jason Merrill jason@cygnus.com
Fri Feb 5 02:41:00 GMT 1999


In some cases (such as with -fprofile-arcs -ftest-coverage), the backend
generates FUNCTION_DECLs that don't have LANG_SPECIFIC info.  We should fix
that.

Fixes g++.robertl/eb83.C.

1999-02-04  Jason Merrill  <jason@yorick.cygnus.com>

	* lex.c (retrofit_lang_decl): Split out...
	(build_lang_decl): From here.
	* decl.c (pushdecl): Call it for functions generated by the middle 
	end that don't have DECL_LANG_SPECIFIC.

Index: lex.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/cp/lex.c,v
retrieving revision 1.99
diff -c -p -r1.99 lex.c
*** lex.c	1999/01/14 10:42:10	1.99
--- lex.c	1999/02/05 10:40:31
*************** build_lang_decl (code, name, type)
*** 4561,4566 ****
--- 4561,4577 ----
       tree type;
  {
    register tree t = build_decl (code, name, type);
+   retrofit_lang_decl (t);
+   return t;
+ }
+ 
+ /* Add DECL_LANG_SPECIFIC info to T.  Called from build_lang_decl
+    and pushdecl (for functions generated by the backend).  */
+ 
+ void
+ retrofit_lang_decl (t)
+      tree t;
+ {
    struct obstack *obstack = current_obstack;
    register int i = sizeof (struct lang_decl) / sizeof (int);
    register int *pi;
*************** build_lang_decl (code, name, type)
*** 4609,4616 ****
    tree_node_counts[(int)lang_decl] += 1;
    tree_node_sizes[(int)lang_decl] += sizeof (struct lang_decl);
  #endif
- 
-   return t;
  }
  
  tree
--- 4620,4625 ----
Index: decl.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/cp/decl.c,v
retrieving revision 1.305
diff -c -p -r1.305 decl.c
*** decl.c	1999/01/28 09:47:48	1.305
--- decl.c	1999/02/05 10:40:31
*************** pushdecl (x)
*** 3671,3676 ****
--- 3671,3685 ----
  
        check_template_shadow (x);
  
+       /* If this is a function conjured up by the backend, massage it
+ 	 so it looks friendly.  */
+       if (TREE_CODE (x) == FUNCTION_DECL
+ 	  && ! DECL_LANG_SPECIFIC (x))
+ 	{
+ 	  retrofit_lang_decl (x);
+ 	  DECL_LANGUAGE (x) = lang_c;
+ 	}
+ 
        if (TREE_CODE (x) == FUNCTION_DECL && ! DECL_FUNCTION_MEMBER_P (x))
  	{
  	  t = push_overloaded_decl (x, PUSH_LOCAL);


More information about the Gcc-patches mailing list