summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaTemplate.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2011-10-20 16:41:18 +0000
committerDouglas Gregor <dgregor@apple.com>2011-10-20 16:41:18 +0000
commit44e5a0a72b778627d8be3cd45340024c003666ac (patch)
tree150f6d92fa6cd8b3586177ab7e7ae6cd81f82614 /clang/lib/Sema/SemaTemplate.cpp
parentf65d8ffca7b2ffe6227b91e82e4f40f2d0c09c75 (diff)
downloadbcm5719-llvm-44e5a0a72b778627d8be3cd45340024c003666ac.tar.gz
bcm5719-llvm-44e5a0a72b778627d8be3cd45340024c003666ac.zip
Diagnose class template (partial) specializations that occur in the
*wrong* class scope. This is one of the problems behind <rdar://problem/9676205>. llvm-svn: 142588
Diffstat (limited to 'clang/lib/Sema/SemaTemplate.cpp')
-rw-r--r--clang/lib/Sema/SemaTemplate.cpp11
1 files changed, 10 insertions, 1 deletions
diff --git a/clang/lib/Sema/SemaTemplate.cpp b/clang/lib/Sema/SemaTemplate.cpp
index 00cc9b53b6d..8bfcde60920 100644
--- a/clang/lib/Sema/SemaTemplate.cpp
+++ b/clang/lib/Sema/SemaTemplate.cpp
@@ -4565,12 +4565,21 @@ static bool CheckTemplateSpecializationScope(Sema &S,
}
}
+ if (S.CurContext->isRecord() &&
+ !S.CurContext->Equals(Specialized->getDeclContext())) {
+ // Make sure that we're specializing in the right record context.
+ // Otherwise, things can go horribly wrong.
+ S.Diag(Loc, diag::err_template_spec_decl_class_scope)
+ << Specialized;
+ return true;
+ }
+
// 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 ((!PrevDecl ||
OpenPOWER on IntegriCloud