(C++) patch to de-anonymizing

Jason Merrill jason@cygnus.com
Mon Jun 28 00:12:00 GMT 1999


When a type is de-anonymized, its variants should be, too.

Applied to main branch.

1999-06-28  Jason Merrill  <jason@yorick.cygnus.com>

	* decl.c (grokdeclarator): Update the names of all variants when
	de-anonymizing.

Index: decl.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/cp/decl.c,v
retrieving revision 1.373
diff -c -p -r1.373 decl.c
*** decl.c	1999/06/19 11:11:41	1.373
--- decl.c	1999/06/28 07:09:56
*************** grokdeclarator (declarator, declspecs, d
*** 11066,11083 ****
  	  && TREE_CODE (TYPE_NAME (type)) == TYPE_DECL
  	  && ANON_AGGRNAME_P (TYPE_IDENTIFIER (type)))
  	{
  	  /* FIXME: This is bogus; we should not be doing this for
  	            cv-qualified types.  */
  
- 	  /* For anonymous structs that are cv-qualified, need to use
-              TYPE_MAIN_VARIANT so that name will mangle correctly. As
-              type not referenced after this block, don't bother
-              resetting type to original type, ie. TREE_TYPE (decl). */
- 	  type = TYPE_MAIN_VARIANT (type);
- 
  	  /* Replace the anonymous name with the real name everywhere.  */
  	  lookup_tag_reverse (type, declarator);
! 	  TYPE_NAME (type) = decl;
  
  	  if (TYPE_LANG_SPECIFIC (type))
  	    TYPE_WAS_ANONYMOUS (type) = 1;
--- 11066,11082 ----
  	  && TREE_CODE (TYPE_NAME (type)) == TYPE_DECL
  	  && ANON_AGGRNAME_P (TYPE_IDENTIFIER (type)))
  	{
+ 	  tree oldname = TYPE_NAME (type);
+ 	  tree t;
+ 
  	  /* FIXME: This is bogus; we should not be doing this for
  	            cv-qualified types.  */
  
  	  /* Replace the anonymous name with the real name everywhere.  */
  	  lookup_tag_reverse (type, declarator);
! 	  for (t = TYPE_MAIN_VARIANT (type); t; t = TYPE_NEXT_VARIANT (t))
! 	    if (TYPE_NAME (t) == oldname)
! 	      TYPE_NAME (t) = decl;
  
  	  if (TYPE_LANG_SPECIFIC (type))
  	    TYPE_WAS_ANONYMOUS (type) = 1;


More information about the Gcc-patches mailing list