diff options
author | Hans Wennborg <hans@hanshq.net> | 2018-01-17 16:15:39 +0000 |
---|---|---|
committer | Hans Wennborg <hans@hanshq.net> | 2018-01-17 16:15:39 +0000 |
commit | ca189f00affcf3554b5fe84d0fff980620055f8b (patch) | |
tree | d40d4b63303557e0dcd71b8aff5f1d799077af27 | |
parent | 2dfe2bdba5bc7a7401e1023cd794ad362a24742d (diff) |
Merging r321779:
------------------------------------------------------------------------
r321779 | rsmith | 2018-01-03 17:24:17 -0800 (Wed, 03 Jan 2018) | 7 lines
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/branches/release_60@322677 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/Sema/SemaTemplateDeduction.cpp | 4 | ||||
-rw-r--r-- | test/SemaCXX/cxx1z-class-template-argument-deduction.cpp | 11 |
2 files changed, 15 insertions, 0 deletions
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<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)) { 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<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 |