]> granicus.if.org Git - clang/commitdiff
PR35045: Convert injected-class-name to its corresponding simple-template-id
authorRichard Smith <richard-llvm@metafoo.co.uk>
Thu, 4 Jan 2018 01:24:17 +0000 (01:24 +0000)
committerRichard Smith <richard-llvm@metafoo.co.uk>
Thu, 4 Jan 2018 01:24:17 +0000 (01:24 +0000)
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

lib/Sema/SemaTemplateDeduction.cpp
test/SemaCXX/cxx1z-class-template-argument-deduction.cpp

index 3a0f2ff0004bebf687f5f0f38c7dbb45231cf3b1..d09cf9933ecf46f92f23f685f8f9cc3d27deddb9 100644 (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)) {
index 9080f67fe0e11363df344c70525b9a275c5872ec..d21fbf28928997f36540a1cba3ab0ddec1a81525 100644 (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