diff options
author | Douglas Gregor <dgregor@apple.com> | 2009-02-06 22:42:48 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2009-02-06 22:42:48 +0000 |
commit | cd72ba97e73f514ccb12212184e1312268b8bebe (patch) | |
tree | 9d6197b565008720775400978e22df5fcdfb79f6 /clang/lib/Parse/ParseDeclCXX.cpp | |
parent | dc93bbc4b07eb30cfb13ea70fcb801b189f3ef5b (diff) | |
download | bcm5719-llvm-cd72ba97e73f514ccb12212184e1312268b8bebe.tar.gz bcm5719-llvm-cd72ba97e73f514ccb12212184e1312268b8bebe.zip |
Semantic checking for class template declarations and
redeclarations. For example, checks that a class template
redeclaration has the same template parameters as previous
declarations.
Detangled class-template checking from ActOnTag, whose logic was
getting rather convoluted because it tried to handle C, C++, and C++
template semantics in one shot.
Made some inroads toward eliminating extraneous "declaration does not
declare anything" errors by adding an "error" type specifier.
llvm-svn: 63973
Diffstat (limited to 'clang/lib/Parse/ParseDeclCXX.cpp')
-rw-r--r-- | clang/lib/Parse/ParseDeclCXX.cpp | 30 |
1 files changed, 20 insertions, 10 deletions
diff --git a/clang/lib/Parse/ParseDeclCXX.cpp b/clang/lib/Parse/ParseDeclCXX.cpp index b2b0d8f59fa..59c086f8131 100644 --- a/clang/lib/Parse/ParseDeclCXX.cpp +++ b/clang/lib/Parse/ParseDeclCXX.cpp @@ -345,14 +345,17 @@ void Parser::ParseClassSpecifier(DeclSpec &DS, return; } - // Create the tag portion of the class, possibly resulting in a template. - DeclTy *TagOrTempDecl - = Actions.ActOnTag(CurScope, TagType, TK, StartLoc, SS, Name, - NameLoc, Attr, - Action::MultiTemplateParamsArg( - Actions, - TemplateParams? &(*TemplateParams)[0] : 0, - TemplateParams? TemplateParams->size() : 0)); + // Create the tag portion of the class or class template. + DeclTy *TagOrTempDecl; + if (TemplateParams && TK != Action::TK_Reference) + TagOrTempDecl = Actions.ActOnClassTemplate(CurScope, TagType, TK, StartLoc, + SS, Name, NameLoc, Attr, + Action::MultiTemplateParamsArg(Actions, + &(*TemplateParams)[0], + TemplateParams->size())); + else + TagOrTempDecl = Actions.ActOnTag(CurScope, TagType, TK, StartLoc, SS, Name, + NameLoc, Attr); // Parse the optional base clause (C++ only). if (getLang().CPlusPlus && Tok.is(tok::colon)) { @@ -372,7 +375,9 @@ void Parser::ParseClassSpecifier(DeclSpec &DS, } const char *PrevSpec = 0; - if (DS.SetTypeSpecType(TagType, StartLoc, PrevSpec, TagOrTempDecl)) + if (!TagOrTempDecl) + DS.SetTypeSpecError(); + else if (DS.SetTypeSpecType(TagType, StartLoc, PrevSpec, TagOrTempDecl)) Diag(StartLoc, diag::err_invalid_decl_spec_combination) << PrevSpec; } @@ -731,7 +736,12 @@ void Parser::ParseCXXMemberSpecification(SourceLocation RecordLoc, // Enter a scope for the class. ParseScope ClassScope(this, Scope::ClassScope|Scope::DeclScope); - Actions.ActOnTagStartDefinition(CurScope, TagDecl); + if (TagDecl) + Actions.ActOnTagStartDefinition(CurScope, TagDecl); + else { + SkipUntil(tok::r_brace, false, false); + return; + } // C++ 11p3: Members of a class defined with the keyword class are private // by default. Members of a class defined with the keywords struct or union |