[cfe-commits] r84148 - /cfe/trunk/lib/Sema/SemaTemplate.cpp
Douglas Gregor
dgregor at apple.com
Wed Oct 14 14:46:58 PDT 2009
Author: dgregor
Date: Wed Oct 14 16:46:58 2009
New Revision: 84148
URL: http://llvm.org/viewvc/llvm-project?rev=84148&view=rev
Log:
Reuse some code for checking the scope of an explicit instantiation
Modified:
cfe/trunk/lib/Sema/SemaTemplate.cpp
Modified: cfe/trunk/lib/Sema/SemaTemplate.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplate.cpp?rev=84148&r1=84147&r2=84148&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaTemplate.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplate.cpp Wed Oct 14 16:46:58 2009
@@ -3573,26 +3573,21 @@
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
More information about the cfe-commits
mailing list