aboutsummaryrefslogtreecommitdiff
path: root/lib/Parse/ParseDeclCXX.cpp
diff options
context:
space:
mode:
authorJohn McCall <rjmccall@apple.com>2009-12-19 21:48:58 +0000
committerJohn McCall <rjmccall@apple.com>2009-12-19 21:48:58 +0000
commitbd0dfa5c37d422427080a0ae3af9b63e70e6e854 (patch)
tree90d8a20362104d591ac022b2266c00b6e3270d5b /lib/Parse/ParseDeclCXX.cpp
parentc5a857fa5619be83e9154c966db6123724fb3c9e (diff)
Parse base specifiers within the scope of the class. This is possibly not
quite right; I'll come back to it later. It does fix PR 5741. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@91789 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Parse/ParseDeclCXX.cpp')
-rw-r--r--lib/Parse/ParseDeclCXX.cpp30
1 files changed, 18 insertions, 12 deletions
diff --git a/lib/Parse/ParseDeclCXX.cpp b/lib/Parse/ParseDeclCXX.cpp
index d4d19a0b07..fcbbce1062 100644
--- a/lib/Parse/ParseDeclCXX.cpp
+++ b/lib/Parse/ParseDeclCXX.cpp
@@ -852,20 +852,14 @@ void Parser::ParseClassSpecifier(tok::TokenKind TagTokKind,
SS, Name, StartLoc, NameLoc);
}
- // Parse the optional base clause (C++ only).
- if (getLang().CPlusPlus && Tok.is(tok::colon))
- ParseBaseClause(TagOrTempResult.get());
-
// If there is a body, parse it and inform the actions module.
- if (Tok.is(tok::l_brace))
+ if (TUK == Action::TUK_Definition) {
+ assert(Tok.is(tok::l_brace) ||
+ (getLang().CPlusPlus && Tok.is(tok::colon)));
if (getLang().CPlusPlus)
ParseCXXMemberSpecification(StartLoc, TagType, TagOrTempResult.get());
else
ParseStructUnionBody(StartLoc, TagType, TagOrTempResult.get());
- else if (TUK == Action::TUK_Definition) {
- // FIXME: Complain that we have a base-specifier list but no
- // definition.
- Diag(Tok, diag::err_expected_lbrace);
}
void *Result;
@@ -1364,8 +1358,6 @@ void Parser::ParseCXXMemberSpecification(SourceLocation RecordLoc,
PP.getSourceManager(),
"parsing struct/union/class body");
- SourceLocation LBraceLoc = ConsumeBrace();
-
// Determine whether this is a top-level (non-nested) class.
bool TopLevelClass = ClassStack.empty() ||
CurScope->isInCXXInlineMethodScope();
@@ -1378,7 +1370,21 @@ void Parser::ParseCXXMemberSpecification(SourceLocation RecordLoc,
if (TagDecl)
Actions.ActOnTagStartDefinition(CurScope, TagDecl);
- else {
+
+ if (Tok.is(tok::colon)) {
+ ParseBaseClause(TagDecl);
+
+ if (!Tok.is(tok::l_brace)) {
+ Diag(Tok, diag::err_expected_lbrace_after_base_specifiers);
+ return;
+ }
+ }
+
+ assert(Tok.is(tok::l_brace));
+
+ SourceLocation LBraceLoc = ConsumeBrace();
+
+ if (!TagDecl) {
SkipUntil(tok::r_brace, false, false);
return;
}