// Check that the return type is written as a specialization of
// the template specified as the deduction-guide's name.
+ // The template name may not be qualified. [temp.deduct.guide]
ParsedType TrailingReturnType = Chunk.Fun.getTrailingReturnType();
TypeSourceInfo *TSI = nullptr;
QualType RetTy = GetTypeFromParser(TrailingReturnType, &TSI);
TemplateName SpecifiedName = RetTST.getTypePtr()->getTemplateName();
bool TemplateMatches =
Context.hasSameTemplateName(SpecifiedName, GuidedTemplate);
- // FIXME: We should consider other template kinds (using, qualified),
- // otherwise we will emit bogus diagnostics.
- if (SpecifiedName.getKind() == TemplateName::Template && TemplateMatches)
+ auto TKind = SpecifiedName.getKind();
+ // A Using TemplateName can't actually be valid (either it's qualified, or
+ // we're in the wrong scope). But we have diagnosed these problems
+ // already.
+ bool SimplyWritten = TKind == TemplateName::Template ||
+ TKind == TemplateName::UsingTemplate;
+ if (SimplyWritten && TemplateMatches)
AcceptableReturnType = true;
else {
// This could still instantiate to the right type, unless we know it
}
using N::NamedNS1;
NamedNS1(int) -> NamedNS1<int>; // expected-error {{deduction guide must be declared in the same scope as template}}
- // FIXME: remove the following bogus diagnostic
- // expected-error@-2{{deduction guide is not written as a specialization of template 'NamedNS1'}}
using namespace N;
NamedNS2(int) -> NamedNS2<int>; // expected-error {{deduction guide must be declared in the same scope as template}}