aboutsummaryrefslogtreecommitdiff
path: root/lib/Sema/SemaTemplate.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2009-11-12 00:46:20 +0000
committerDouglas Gregor <dgregor@apple.com>2009-11-12 00:46:20 +0000
commit8b13c08b1a181b290600814c765f9f199a74f414 (patch)
tree59f604da0d01f6e82c7db0d96eb6c17c07937f12 /lib/Sema/SemaTemplate.cpp
parent1144c218f5d74f2270ebcd5ddd82dc472790eaef (diff)
Improve recovery in a wonky case where one tries to specialize a
template template parameter. When building a template-id type, check whether the template-name itself is dependent (even if the template arguments are not!) and handle it as a template-id type. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86913 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaTemplate.cpp')
-rw-r--r--lib/Sema/SemaTemplate.cpp13
1 files changed, 11 insertions, 2 deletions
diff --git a/lib/Sema/SemaTemplate.cpp b/lib/Sema/SemaTemplate.cpp
index 9305d6ebb1..419347adcf 100644
--- a/lib/Sema/SemaTemplate.cpp
+++ b/lib/Sema/SemaTemplate.cpp
@@ -1188,7 +1188,9 @@ QualType Sema::CheckTemplateIdType(TemplateName Name,
if (TemplateSpecializationType::anyDependentTemplateArguments(
TemplateArgs,
- NumTemplateArgs)) {
+ NumTemplateArgs) ||
+ isa<TemplateTemplateParmDecl>(Template) ||
+ Template->getDeclContext()->isDependentContext()) {
// This class template specialization is a dependent
// type. Therefore, its canonical type is another class template
// specialization type that contains all of the converted
@@ -2935,7 +2937,14 @@ Sema::ActOnClassTemplateSpecialization(Scope *S, unsigned TagSpec,
// Find the class template we're specializing
TemplateName Name = TemplateD.getAsVal<TemplateName>();
ClassTemplateDecl *ClassTemplate
- = cast<ClassTemplateDecl>(Name.getAsTemplateDecl());
+ = dyn_cast_or_null<ClassTemplateDecl>(Name.getAsTemplateDecl());
+
+ if (!ClassTemplate) {
+ Diag(TemplateNameLoc, diag::err_not_class_template_specialization)
+ << (Name.getAsTemplateDecl() &&
+ isa<TemplateTemplateParmDecl>(Name.getAsTemplateDecl()));
+ return true;
+ }
bool isExplicitSpecialization = false;
bool isPartialSpecialization = false;