[cfe-commits] r91789 - in /cfe/trunk: include/clang/Basic/DiagnosticParseKinds.td lib/Parse/ParseDeclCXX.cpp test/CXX/basic/basic.lookup/basic.lookup.unqual/p7.cpp
John McCall
rjmccall at apple.com
Sat Dec 19 13:48:58 PST 2009
Author: rjmccall
Date: Sat Dec 19 15:48:58 2009
New Revision: 91789
URL: http://llvm.org/viewvc/llvm-project?rev=91789&view=rev
Log:
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.
Added:
cfe/trunk/test/CXX/basic/basic.lookup/basic.lookup.unqual/p7.cpp
Modified:
cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
cfe/trunk/lib/Parse/ParseDeclCXX.cpp
Modified: cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td?rev=91789&r1=91788&r2=91789&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td Sat Dec 19 15:48:58 2009
@@ -229,6 +229,8 @@
"parentheses were disambiguated as a function declarator">;
def err_expected_member_or_base_name : Error<
"expected class member or base class name">;
+def err_expected_lbrace_after_base_specifiers : Error<
+ "expected '{' after base class list">;
def ext_ellipsis_exception_spec : Extension<
"exception specification of '...' is a Microsoft extension">;
def err_expected_catch : Error<"expected catch">;
Modified: cfe/trunk/lib/Parse/ParseDeclCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDeclCXX.cpp?rev=91789&r1=91788&r2=91789&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseDeclCXX.cpp (original)
+++ cfe/trunk/lib/Parse/ParseDeclCXX.cpp Sat Dec 19 15:48:58 2009
@@ -852,20 +852,14 @@
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 @@
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 @@
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;
}
Added: cfe/trunk/test/CXX/basic/basic.lookup/basic.lookup.unqual/p7.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/basic/basic.lookup/basic.lookup.unqual/p7.cpp?rev=91789&view=auto
==============================================================================
--- cfe/trunk/test/CXX/basic/basic.lookup/basic.lookup.unqual/p7.cpp (added)
+++ cfe/trunk/test/CXX/basic/basic.lookup/basic.lookup.unqual/p7.cpp Sat Dec 19 15:48:58 2009
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// PR5741
+struct A {
+ struct B { };
+ struct C;
+};
+
+struct A::C : B { };
More information about the cfe-commits
mailing list