On Mon, Jan 28, 2019 at 11:37 PM Alexandre Oliva <aol...@redhat.com> wrote:
> On Jan 27, 2019, Jason Merrill <ja...@redhat.com> wrote:
>
> >> +     ??? How do we
> >> +     tell apart a partial from a full explicit specialization in a
> >> +     non-template context?  */
>
> > We don't need to tell them apart here, the caller checks if there are
> > any dependent template arguments.
>
> The single caller does, indeed, but the function does not make that a
> requirement, so others might call it and fail to check it.  Should that
> test be moved here too?

Hmm, I wouldn't expect that from a function named
"instantiates_primary_template_p".

Perhaps another function that calls instantiates_primary_template_p
and then checks for dependent innermost template args?  I'm not sure
what to call that function, perhaps decl_has_dependent_primary_targs?

> Anyhow, the question was really about the fact that the non-template
> context has no template argument depth for us to compare with.  When I
> wrote that comment, I was returning true for !ctinfo, unconditionally,
> reasoning that if NODE's context is not a template, then NODE must
> specialize some a primary template.

Right.

> But if we want partial but not full
> explicit specializations, then just having a deeper (or nonzero)
> template argument depth is not enough, is it?

See above.  Though we're not necessarily dealing with explicit
specializations at all here, what we have is a decl produced from a
template and some args, which might or might not be specialized.

> >> +  tree ctxt;
> >> +  if (!DECL_P (node))
> >> +    ctxt = TYPE_CONTEXT (node);
> >> +  else
> >> +    ctxt = DECL_CONTEXT (node);
>
> > We know tmpl is a decl, so we can unconditionally take its DECL_CONTEXT.
>
> Does it hurt too much to keep it more general, so that it can deal with
> template class types too?

A class template also comes from a TEMPLATE_DECL; either way, tmpl is
a TEMPLATE_DECL.

Note that I'm talking about the "tmpl" variable, not "node".

Jason

Reply via email to