This is the mail archive of the 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++/10682 caused by patch for c++/7639

Jason Merrill wrote:

Your change

2002-10-30 Kriang Lerdsuwanakij <>

	* pt.c (instantiate_class_template): Use CLASSTYPE_DECL_LIST
	to process members and friends in the order of declaration.

broke PR 10682 by changing

! 	/* R will have a TREE_CHAIN if and only if it has already been
! 	   processed by finish_member_declaration.  This can happen
! 	   if, for example, it is a TYPE_DECL for a class-scoped
! 	   ENUMERAL_TYPE; such a thing will already have been added to
! 	   the field list by tsubst_enum above.  */
! 	if (!TREE_CHAIN (r))
! 	  {
! 	    set_current_access_from_decl (r);
! 	    finish_member_declaration (r);
! 	  }


! 		  /* If it is a TYPE_DECL for a class-scoped ENUMERAL_TYPE,
! 		     such a thing will already have been added to the field
! 		     list by tsubst_enum in finish_member_declaration in the
! 		     CLASSTYPE_TAGS case above.  */
! 		  if (!(TREE_CODE (r) == TYPE_DECL
! 			&& TYPE_CONTEXT (TREE_TYPE (r)) == type))
! 		    {
! 		      set_current_access_from_decl (r);
! 		      finish_member_declaration (r);
! 		    }

The test condition '!TREE_CHAIN (r)' is no longer valid because the order
of template substitution changes.  Previously in GCC 3.2, all tags are
processed first so that any enum that is already processed has a
TREE_CHAIN (with tag for class itself appearing the last node in the chain).

Now declarations are always process in the order of appearance.  The tag,
its constants, and TYPE_DECL for an enum are handled consecutively.
So when we are dealing with the TYPE_DECL, the recently pushed tag is
always at the end of list with TREE_CHAIN being NULL_TREE.

The reduced testcase for 10682 contains a class-scope typedef of enum type, but the above comment doesn't apply to it because it isn't an artificial typedef. This bug can be fixed by adding


to the new code,

This is a correct fix.  There may be some better solution for this but I
don't have one right now.  I'll prepare a patch and testcase using the
above fix.

Sorry for the regression.


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