r321779 - PR35045: Convert injected-class-name to its corresponding simple-template-id
Hans Wennborg via cfe-commits
cfe-commits at lists.llvm.org
Wed Jan 17 08:17:24 PST 2018
Merged to 6.0 in r322677.
On Thu, Jan 4, 2018 at 2:24 AM, Richard Smith via cfe-commits
<cfe-commits at lists.llvm.org> wrote:
> Author: rsmith
> Date: Wed Jan 3 17:24:17 2018
> New Revision: 321779
>
> URL: http://llvm.org/viewvc/llvm-project?rev=321779&view=rev
> Log:
> 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.
>
> Modified:
> cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp
> cfe/trunk/test/SemaCXX/cxx1z-class-template-argument-deduction.cpp
>
> Modified: cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp?rev=321779&r1=321778&r2=321779&view=diff
> ==============================================================================
> --- cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp (original)
> +++ cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp Wed Jan 3 17:24:17 2018
> @@ -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)) {
>
> Modified: cfe/trunk/test/SemaCXX/cxx1z-class-template-argument-deduction.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/cxx1z-class-template-argument-deduction.cpp?rev=321779&r1=321778&r2=321779&view=diff
> ==============================================================================
> --- cfe/trunk/test/SemaCXX/cxx1z-class-template-argument-deduction.cpp (original)
> +++ cfe/trunk/test/SemaCXX/cxx1z-class-template-argument-deduction.cpp Wed Jan 3 17:24:17 2018
> @@ -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
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
More information about the cfe-commits
mailing list