]> granicus.if.org Git - clang/commitdiff
Weaken restriction in r304862 to allow implicit deduction guides to reference
authorRichard Smith <richard-llvm@metafoo.co.uk>
Thu, 8 Jun 2017 01:08:50 +0000 (01:08 +0000)
committerRichard Smith <richard-llvm@metafoo.co.uk>
Thu, 8 Jun 2017 01:08:50 +0000 (01:08 +0000)
the injected-class-name of a specialization that uses a partial / explicit
specialization.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@304957 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Sema/Sema.h
lib/Sema/SemaTemplateInstantiateDecl.cpp
test/SemaCXX/cxx1z-class-template-argument-deduction.cpp

index 275039fc0a27b7730352f691afb41d5c4091c550..b109ca03377c8f61f7ed08daa3dba893f930195e 100644 (file)
@@ -7721,7 +7721,8 @@ public:
                             const MultiLevelTemplateArgumentList &TemplateArgs);
 
   NamedDecl *FindInstantiatedDecl(SourceLocation Loc, NamedDecl *D,
-                          const MultiLevelTemplateArgumentList &TemplateArgs);
+                          const MultiLevelTemplateArgumentList &TemplateArgs,
+                          bool FindingInstantiatedContext = false);
   DeclContext *FindInstantiatedContext(SourceLocation Loc, DeclContext *DC,
                           const MultiLevelTemplateArgumentList &TemplateArgs);
 
index 9e8b4d55d63e8f129e2cbf0ade23eb307c4a3322..148ce24293a09deaab196a75b4d01b85d5d54c19 100644 (file)
@@ -4807,7 +4807,7 @@ static NamedDecl *findInstantiationOf(ASTContext &Ctx,
 DeclContext *Sema::FindInstantiatedContext(SourceLocation Loc, DeclContext* DC,
                           const MultiLevelTemplateArgumentList &TemplateArgs) {
   if (NamedDecl *D = dyn_cast<NamedDecl>(DC)) {
-    Decl* ID = FindInstantiatedDecl(Loc, D, TemplateArgs);
+    Decl* ID = FindInstantiatedDecl(Loc, D, TemplateArgs, true);
     return cast_or_null<DeclContext>(ID);
   } else return DC;
 }
@@ -4839,7 +4839,8 @@ DeclContext *Sema::FindInstantiatedContext(SourceLocation Loc, DeclContext* DC,
 /// (<tt>X<int>::<Kind>::KnownValue</tt>). \p FindInstantiatedDecl performs
 /// this mapping from within the instantiation of <tt>X<int></tt>.
 NamedDecl *Sema::FindInstantiatedDecl(SourceLocation Loc, NamedDecl *D,
-                          const MultiLevelTemplateArgumentList &TemplateArgs) {
+                          const MultiLevelTemplateArgumentList &TemplateArgs,
+                          bool FindingInstantiatedContext) {
   DeclContext *ParentDC = D->getDeclContext();
   // FIXME: Parmeters of pointer to functions (y below) that are themselves 
   // parameters (p below) can have their ParentDC set to the translation-unit
@@ -5007,8 +5008,9 @@ NamedDecl *Sema::FindInstantiatedDecl(SourceLocation Loc, NamedDecl *D,
           // meaningless to attempt to find an instantiation of D within the
           // specialization.)
           // FIXME: The standard doesn't say what should happen here.
-          if (usesPartialOrExplicitSpecialization(Loc,
-                cast<ClassTemplateSpecializationDecl>(SubstRecord))) {
+          if (FindingInstantiatedContext &&
+              usesPartialOrExplicitSpecialization(
+                  Loc, cast<ClassTemplateSpecializationDecl>(SubstRecord))) {
             Diag(Loc, diag::err_specialization_not_primary_template)
               << T << (SubstRecord->getTemplateSpecializationKind() ==
                            TSK_ExplicitSpecialization);
index ede2844c235a594a3643bbf500d0778eeb54e446..159b7072e61e54675c84718cb93f3c40c27931d4 100644 (file)
@@ -271,4 +271,12 @@ namespace tuple_tests {
     template <> class tuple<> {};
     tuple a = {1, 2, 3}; // expected-error {{no viable constructor or deduction guide}}
   }
+
+  namespace libcxx_3 {
+    template<typename ...T> struct scoped_lock {
+      scoped_lock(T...);
+    };
+    template<> struct scoped_lock<> {};
+    scoped_lock l = {};
+  }
 }