From: Douglas Gregor Date: Wed, 14 Oct 2009 21:46:58 +0000 (+0000) Subject: Reuse some code for checking the scope of an explicit instantiation X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a74bbe2c9fb8f83db393a584e8a1da8c40182542;p=clang 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 --- 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(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