PR35045: Convert injected-class-name to its corresponding simple-template-id

during template argument deduction.

We already did this when the injected-class-name was in P, but missed the case
where it was in A. This (probably) can't happen except in implicit deduction
guides.

llvm-svn: 321779
This commit is contained in:
Richard Smith 2018-01-04 01:24:17 +00:00
parent 8fbad0a4c2
commit 1337318eea
2 changed files with 15 additions and 0 deletions

View File

@ -502,6 +502,10 @@ DeduceTemplateArguments(Sema &S,
SmallVectorImpl<DeducedTemplateArgument> &Deduced) {
assert(Arg.isCanonical() && "Argument type must be canonical");
// Treat an injected-class-name as its underlying template-id.
if (auto *Injected = dyn_cast<InjectedClassNameType>(Arg))
Arg = Injected->getInjectedSpecializationType();
// Check whether the template argument is a dependent template-id.
if (const TemplateSpecializationType *SpecArg
= dyn_cast<TemplateSpecializationType>(Arg)) {

View File

@ -309,6 +309,17 @@ namespace dependent {
template int New(int);
}
namespace injected_class_name {
template<typename T = void> struct A {
A();
template<typename U> A(A<U>);
};
A<int> a;
A b = a;
using T = decltype(a);
using T = decltype(b);
}
#else
// expected-no-diagnostics