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]

Re: C++: template in namespace


>   +      if (processing_template_decl || processing_specialization)
>   +	/* We have not reduced the fndef to template_def, yet, so
>   +	   the decls don't match.  */
> 
> Don't use these funny abbreviations.  "Reduced", "fndef", and
> "template_def" are not terms of art in the compiler.  I bet you mean
> something like this:
> 
>   /* We have not yet called push_template_decl to turn the
>      FUNCTION_DECL into a TEMPLATE_DECL, so the declarations
>      won't match.  But, we'll check later, when ...?  */

No, I meant exactly that. There is a rule in parse.y

template_def:
	  template_header template_extdef
                { finish_template_decl ($1); }

and we can "reduce" (in the bison sense) the fndef nonterminal using

template_extdef:
	  fndef eat_saved_input
		{ if (pending_inlines) do_pending_inlines (); }

So, we have not "combined" the template header with the function, and
only have the function.

Of course, my comment was wrong, as this combination is not achieved
by finish_template_decl (as I had expected), but by some other magic
means which I don't understand.

Your analysis is right; this is the real reason.

Cheers,
Martin


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