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]

Re: [PATCH] Fix PR debug/14114 [DWARF2 guru needed]


> Much, much ado about nothing... the patch is broken, it causes a bootstrap
> failure on PA.  I've reverted it, checked in a reduced testcase and
> XFAILed the first testcase.
>
> We might need to resort to hacking dwarf2out.c after all... oh well.

Maybe not.  Here is a second, not hackish, attempt at fixing the C front-end.

I think there are actually 2 problems:
- pushdecl uses IDENTIFIER_SYMBOL_VALUE (name) to search for a previous 
decl that the current decl is shadowing.  This is wrong and the real cause of 
the failure of the PR.  The correct way is to use lookup_name, which is 
essentially IDENTIFIER_SYMBOL_VALUE (name) but tests the C_DECL_INVISIBLE 
flag that is set by poplevel to hide decls from previous scopes.  But this 
doesn't cure the ICE because...
- C_DECL_INVISIBLE is botchered by merge_decls.  I think merge_decls must not 
copy the flag from the new decl to the old decl because this causes the old 
decl to be automatically visible in the current scope.


Bootstrapped/regtested on i586-redhat-linux (3.4 branch), including testcases 
for the PR and the bootstrap failure on PA.  OK for mainline and 3.4 branch?


2004-03-08  Eric Botcazou  <ebotcazou@libertysurf.fr>

        PR c/14114
	* c-decl.c (merge_decls): Do not copy the C_DECL_INVISIBLE flag
	from the new decl to the old decl.
	(pushdecl): Use lookup_name to search for a previous decl with the
	same identifier.


-- 
Eric Botcazou
Index: c-decl.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/c-decl.c,v
retrieving revision 1.470.4.8
diff -u -p -r1.470.4.8 c-decl.c
--- c-decl.c	7 Mar 2004 00:39:02 -0000	1.470.4.8
+++ c-decl.c	8 Mar 2004 09:22:37 -0000
@@ -1478,14 +1478,16 @@ merge_decls (tree newdecl, tree olddecl,
     }
 
   /* Copy most of the decl-specific fields of NEWDECL into OLDDECL.
-     But preserve OLDDECL's DECL_UID.  */
+     But preserve OLDDECL's DECL_UID and C_DECL_INVISIBLE.  */
   {
     unsigned olddecl_uid = DECL_UID (olddecl);
+    unsigned olddecl_invisible = C_DECL_INVISIBLE (olddecl);
 
     memcpy ((char *) olddecl + sizeof (struct tree_common),
 	    (char *) newdecl + sizeof (struct tree_common),
 	    sizeof (struct tree_decl) - sizeof (struct tree_common));
     DECL_UID (olddecl) = olddecl_uid;
+    C_DECL_INVISIBLE (olddecl) = olddecl_invisible;
   }
 
   /* If OLDDECL had its DECL_RTL instantiated, re-invoke make_decl_rtl
@@ -1737,13 +1739,15 @@ pushdecl (tree x)
 	 scope ends.  Take care not to do this if we are replacing an
 	 older decl in the same scope (i.e.  duplicate_decls returned
 	 false, above).  */
-      if (scope != global_scope
-	  && IDENTIFIER_SYMBOL_VALUE (name)
-	  && IDENTIFIER_SYMBOL_VALUE (name) != old)
+      if (scope != global_scope)
 	{
-	  warn_if_shadowing (x, IDENTIFIER_SYMBOL_VALUE (name));
-	  scope->shadowed = tree_cons (name, IDENTIFIER_SYMBOL_VALUE (name),
-				       scope->shadowed);
+	  tree inherited_decl = lookup_name (name);
+	  if (inherited_decl && inherited_decl != old)
+	    {
+	      warn_if_shadowing (x, inherited_decl);
+	      scope->shadowed = tree_cons (name, inherited_decl,
+					   scope->shadowed);
+	    }
 	}
 
       /* Install the new declaration in the requested scope.  */

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