summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaTemplate.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2009-10-07 17:21:34 +0000
committerDouglas Gregor <dgregor@apple.com>2009-10-07 17:21:34 +0000
commite4b05168f684f325429a8b5ef525a6ee47ea51b1 (patch)
treed84c861391b781a79a772c20228d02053ca22bcd /clang/lib/Sema/SemaTemplate.cpp
parentaa47a8d71adf89ea37c3bfd417b00e39dc77ef45 (diff)
downloadbcm5719-llvm-e4b05168f684f325429a8b5ef525a6ee47ea51b1.tar.gz
bcm5719-llvm-e4b05168f684f325429a8b5ef525a6ee47ea51b1.zip
Class template partial specializations can be declared anywhere that
its definition may be defined, including in a class. Also, put in an assertion when trying to instantiate a class template partial specialization of a member template, which is not yet implemented. llvm-svn: 83469
Diffstat (limited to 'clang/lib/Sema/SemaTemplate.cpp')
-rw-r--r--clang/lib/Sema/SemaTemplate.cpp16
1 files changed, 12 insertions, 4 deletions
diff --git a/clang/lib/Sema/SemaTemplate.cpp b/clang/lib/Sema/SemaTemplate.cpp
index 1addd16bdf4..9d7dd0a0569 100644
--- a/clang/lib/Sema/SemaTemplate.cpp
+++ b/clang/lib/Sema/SemaTemplate.cpp
@@ -2434,11 +2434,19 @@ static bool CheckTemplateSpecializationScope(Sema &S,
return true;
}
+ // FIXME: For everything except class template partial specializations,
+ // complain if the explicit specialization/instantiation occurs at class
+ // scope.
+
+ // C++ [temp.class.spec]p6:
+ // A class template partial specialization may be declared or redeclared
+ // in any namespace scope in which its definition may be defined (14.5.1
+ // and 14.5.2).
bool ComplainedAboutScope = false;
- DeclContext *SpecializedContext
+ DeclContext *SpecializedContext
= Specialized->getDeclContext()->getEnclosingNamespaceContext();
+ DeclContext *DC = S.CurContext->getEnclosingNamespaceContext();
if (TSK == TSK_ExplicitSpecialization) {
- DeclContext *DC = S.CurContext->getEnclosingNamespaceContext();
if ((!PrevDecl ||
getTemplateSpecializationKind(PrevDecl) == TSK_Undeclared ||
getTemplateSpecializationKind(PrevDecl) == TSK_ImplicitInstantiation)){
@@ -2468,8 +2476,8 @@ static bool CheckTemplateSpecializationScope(Sema &S,
// specializations of function templates, static data members, and member
// functions, so we skip the check here for those kinds of entities.
// FIXME: HandleDeclarator's diagnostics aren't quite as good, though.
- // Should we refactor the check, so that it occurs later?
- if (!ComplainedAboutScope && !S.CurContext->Encloses(SpecializedContext) &&
+ // Should we refactor that check, so that it occurs later?
+ if (!ComplainedAboutScope && !DC->Encloses(SpecializedContext) &&
((TSK == TSK_ExplicitSpecialization &&
!(isa<FunctionTemplateDecl>(Specialized) || isa<VarDecl>(Specialized) ||
isa<FunctionDecl>(Specialized))) ||
OpenPOWER on IntegriCloud