]> granicus.if.org Git - clang/commitdiff
Reuse some code for checking the scope of an explicit instantiation
authorDouglas Gregor <dgregor@apple.com>
Wed, 14 Oct 2009 21:46:58 +0000 (21:46 +0000)
committerDouglas Gregor <dgregor@apple.com>
Wed, 14 Oct 2009 21:46:58 +0000 (21:46 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@84148 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaTemplate.cpp

index 457b219bb06e58e6cb19a5819baea5bb91332fed..ce76f4fecc9707889a0d5c68501868b4759bafa9 100644 (file)
@@ -3573,26 +3573,21 @@ Sema::ActOnExplicitInstantiation(Scope *S,
     return true;
   }
 
+  // What kind of explicit instantiation? (for C++0x, GNU extern templates).
+  TemplateSpecializationKind TSK
+    = ExternLoc.isInvalid()? TSK_ExplicitInstantiationDefinition
+                           : TSK_ExplicitInstantiationDeclaration;
+  
   // C++0x [temp.explicit]p2:
   //   [...] An explicit instantiation shall appear in an enclosing
   //   namespace of its template. [...]
   //
   // This is C++ DR 275.
-  if (getLangOptions().CPlusPlus0x) {
-    // FIXME: In C++98, we would like to turn these errors into warnings,
-    // dependent on a -Wc++0x flag.
-    DeclContext *PatternContext
-      = Pattern->getDeclContext()->getEnclosingNamespaceContext();
-    if (!CurContext->Encloses(PatternContext)) {
-      Diag(TemplateLoc, diag::err_explicit_instantiation_out_of_scope)
-        << Record << cast<NamedDecl>(PatternContext) << SS.getRange();
-      Diag(Pattern->getLocation(), diag::note_previous_declaration);
-    }
-  }
-
-  TemplateSpecializationKind TSK
-    = ExternLoc.isInvalid()? TSK_ExplicitInstantiationDefinition
-                           : TSK_ExplicitInstantiationDeclaration;
+  if (CheckTemplateSpecializationScope(*this, Record, 
+                                       Record->getPreviousDeclaration(),
+                                       NameLoc, false, 
+                                       TSK))
+    return true;  
 
   if (!Record->getDefinition(Context)) {
     // If the class has a definition, instantiate it (and all of its