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] PR c++/42824


On Thu, Feb 11, 2010 at 05:45:56PM -0500, Jason Merrill wrote:
> On 02/11/2010 12:07 PM, Dodji Seketeli wrote:
> >+	  /* The enclosing class must be an instantiation ... */
> >+	  CLASS_TYPE_P (template_type)
> >+	&&  TYPE_CONTEXT (template_type)
> >+	&&  CLASS_TYPE_P (TYPE_CONTEXT (template_type))
> >+	&&  CLASSTYPE_TEMPLATE_INFO (TYPE_CONTEXT (template_type))
> >+	&&  DECL_CONTEXT (gen_tmpl)
> >+	&&  CLASS_TYPE_P (DECL_CONTEXT (gen_tmpl))
> >+	&&  CLASSTYPE_TEMPLATE_INFO (DECL_CONTEXT (gen_tmpl))
> >+	&&  tmpl_has_one_outermost_arg_and_parm_not_equivalent_p
> >+	     (arglist, DECL_TEMPLATE_PARMS (gen_tmpl))
> 
> I think this can all be simplified a lot by moving this assignment
> down to the comment "We have to figure out which template is the
> immediate parent," since at that point we've already substituted the
> context. Then it can just be
> 
> context != DECL_CONTEXT (gen_tmpl)
> 
> no?

Consider this example:

template<class T>
struct S
{
  template<class U> struct M; // #0
};

template<class T>
template<class U*>
struct S<T>::M<U*> // #1
{
  int i;
};


If I do what you suggest, at #1, S<T>::M<U*> is considered to be an 
explicit specialization of M with S<T> being an implicit instantiation 
of S, because context != DECL_CONTEXT (gen_tmpl) is verified as the 
lookup of S<T> produces a type.

        Dodji


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