diff options
author | Douglas Gregor <dgregor@apple.com> | 2009-10-14 21:46:58 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2009-10-14 21:46:58 +0000 |
commit | a74bbe2c9fb8f83db393a584e8a1da8c40182542 (patch) | |
tree | dbb04c63fd12ec40f8b27a84e5daa7edef1305d8 /lib/Sema/SemaTemplate.cpp | |
parent | a0f00a71fcb0f98298709d5e5318339acf7958ac (diff) |
Reuse some code for checking the scope of an explicit instantiation
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@84148 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaTemplate.cpp')
-rw-r--r-- | lib/Sema/SemaTemplate.cpp | 25 |
1 files changed, 10 insertions, 15 deletions
diff --git a/lib/Sema/SemaTemplate.cpp b/lib/Sema/SemaTemplate.cpp index 457b219bb0..ce76f4fecc 100644 --- a/lib/Sema/SemaTemplate.cpp +++ b/lib/Sema/SemaTemplate.cpp @@ -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 |