From: Richard Smith Date: Thu, 4 Jan 2018 01:24:17 +0000 (+0000) Subject: PR35045: Convert injected-class-name to its corresponding simple-template-id X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=164f9f70539b170d2be6c78e4408aa3255130b00;p=clang 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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@321779 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/SemaTemplateDeduction.cpp b/lib/Sema/SemaTemplateDeduction.cpp index 3a0f2ff000..d09cf9933e 100644 --- a/lib/Sema/SemaTemplateDeduction.cpp +++ b/lib/Sema/SemaTemplateDeduction.cpp @@ -502,6 +502,10 @@ DeduceTemplateArguments(Sema &S, SmallVectorImpl &Deduced) { assert(Arg.isCanonical() && "Argument type must be canonical"); + // Treat an injected-class-name as its underlying template-id. + if (auto *Injected = dyn_cast(Arg)) + Arg = Injected->getInjectedSpecializationType(); + // Check whether the template argument is a dependent template-id. if (const TemplateSpecializationType *SpecArg = dyn_cast(Arg)) { diff --git a/test/SemaCXX/cxx1z-class-template-argument-deduction.cpp b/test/SemaCXX/cxx1z-class-template-argument-deduction.cpp index 9080f67fe0..d21fbf2892 100644 --- a/test/SemaCXX/cxx1z-class-template-argument-deduction.cpp +++ b/test/SemaCXX/cxx1z-class-template-argument-deduction.cpp @@ -309,6 +309,17 @@ namespace dependent { template int New(int); } +namespace injected_class_name { + template struct A { + A(); + template A(A); + }; + A a; + A b = a; + using T = decltype(a); + using T = decltype(b); +} + #else // expected-no-diagnostics