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++ PATCH] [PR13810] ICE on default argument for template templateparameter (3.4/3.5 regression)

Giovanni Bajo wrote:


cp_parser_id_expression sometimes performs name lookup, sometimes it does not.

It only does name lookup when it sees a template-id, and in that situation it basically has to do name lookup. But, you're right that callers must check for that case.

Moreover, check_template_template_default_arg was accepting TYPE_DECL as a
valid default argument. I can't see how that could have ever been correct. I
fixed it and also provided more detailed diagnostics for common cases.

That's almost certainly a relic of the old parser, which often mixed up types and templates. The other case that you should check, however, is the case where the current template name is used.


 template <typename T>
 struct S {
   template <template <typename> class = S> struct I {};

Assuming that case works, your path is OK for mainline and 3.4, with Gaby's diagnostics changes.

If it fails, you want to do:

 if (TREE_CODE (decl) == TYPE_DECL)
   decl = maybe_get_template_decl_from_type_decl (decl);

before the check_template_template_default_arg code that appears in your patch.

My gut tells me that the additional code I've provided above will be necessary, but I'm not 100% sure.


Mark Mitchell
CodeSourcery, LLC

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