diff options
author | Douglas Gregor <dgregor@apple.com> | 2009-10-30 22:09:44 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2009-10-30 22:09:44 +0000 |
commit | c78c06d81f9838aea4198e4965cc1b26bb0bf838 (patch) | |
tree | b15f5c02e240dd7e8caa7701aeb4d5151fe6b4ec /lib/Parse/ParseDeclCXX.cpp | |
parent | 12e6f0341208099b80e8f6e779cc266d09702cf2 (diff) |
Improved fix for PR3844, which recovers better for class template
partial specializations and explicit instantiations of non-templates.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@85620 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Parse/ParseDeclCXX.cpp')
-rw-r--r-- | lib/Parse/ParseDeclCXX.cpp | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/lib/Parse/ParseDeclCXX.cpp b/lib/Parse/ParseDeclCXX.cpp index 72c9f33cd8..65265afa91 100644 --- a/lib/Parse/ParseDeclCXX.cpp +++ b/lib/Parse/ParseDeclCXX.cpp @@ -617,21 +617,35 @@ void Parser::ParseClassSpecifier(tok::TokenKind TagTokKind, } Diag(NameLoc, diag::err_explicit_spec_non_template) + << (TemplateInfo.Kind == ParsedTemplateInfo::ExplicitInstantiation) << (TagType == DeclSpec::TST_class? 0 : TagType == DeclSpec::TST_struct? 1 : 2) << Name << SourceRange(LAngleLoc, RAngleLoc); - // If this is an explicit specialization, strip off the last template - // parameter list, since we've removed its template arguments. - if (TemplateParams && TemplateParams->size() > 1) { - TemplateParams->pop_back(); - } else { + // Strip off the last template parameter list if it was empty, since + // we've removed its template argument list. + if (TemplateParams && TemplateInfo.LastParameterListWasEmpty) { + if (TemplateParams && TemplateParams->size() > 1) { + TemplateParams->pop_back(); + } else { + TemplateParams = 0; + const_cast<ParsedTemplateInfo&>(TemplateInfo).Kind + = ParsedTemplateInfo::NonTemplate; + } + } else if (TemplateInfo.Kind + == ParsedTemplateInfo::ExplicitInstantiation) { + // Pretend this is just a forward declaration. TemplateParams = 0; const_cast<ParsedTemplateInfo&>(TemplateInfo).Kind = ParsedTemplateInfo::NonTemplate; + const_cast<ParsedTemplateInfo&>(TemplateInfo).TemplateLoc + = SourceLocation(); + const_cast<ParsedTemplateInfo&>(TemplateInfo).ExternLoc + = SourceLocation(); } + } } else if (Tok.is(tok::annot_template_id)) { |