[cfe-commits] r100443 - in /cfe/trunk: include/clang/Parse/Parser.h lib/Parse/ParseDecl.cpp lib/Parse/ParseStmt.cpp test/Parser/cxx-decl.cpp
Chris Lattner
sabre at nondot.org
Mon Apr 5 11:18:31 PDT 2010
Author: lattner
Date: Mon Apr 5 13:18:31 2010
New Revision: 100443
URL: http://llvm.org/viewvc/llvm-project?rev=100443&view=rev
Log:
fix PR6782, an accept invalid. We weren't emitting the diagnostic
returned by SetTypeSpecType.
Modified:
cfe/trunk/include/clang/Parse/Parser.h
cfe/trunk/lib/Parse/ParseDecl.cpp
cfe/trunk/lib/Parse/ParseStmt.cpp
cfe/trunk/test/Parser/cxx-decl.cpp
Modified: cfe/trunk/include/clang/Parse/Parser.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Parse/Parser.h?rev=100443&r1=100442&r2=100443&view=diff
==============================================================================
--- cfe/trunk/include/clang/Parse/Parser.h (original)
+++ cfe/trunk/include/clang/Parse/Parser.h Mon Apr 5 13:18:31 2010
@@ -1086,7 +1086,8 @@
CXX0XAttributeList Attr);
DeclGroupPtrTy ParseSimpleDeclaration(unsigned Context,
SourceLocation &DeclEnd,
- AttributeList *Attr);
+ AttributeList *Attr,
+ bool RequireSemi);
DeclGroupPtrTy ParseDeclGroup(ParsingDeclSpec &DS, unsigned Context,
bool AllowFunctionDefinitions,
SourceLocation *DeclEnd = 0);
Modified: cfe/trunk/lib/Parse/ParseDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDecl.cpp?rev=100443&r1=100442&r2=100443&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseDecl.cpp (original)
+++ cfe/trunk/lib/Parse/ParseDecl.cpp Mon Apr 5 13:18:31 2010
@@ -334,7 +334,7 @@
SingleDecl = ParseStaticAssertDeclaration(DeclEnd);
break;
default:
- return ParseSimpleDeclaration(Context, DeclEnd, Attr.AttrList);
+ return ParseSimpleDeclaration(Context, DeclEnd, Attr.AttrList, true);
}
// This routine returns a DeclGroup, if the thing we parsed only contains a
@@ -348,10 +348,11 @@
/// [OMP] threadprivate-directive [TODO]
///
/// If RequireSemi is false, this does not check for a ';' at the end of the
-/// declaration.
+/// declaration. If it is true, it checks for and eats it.
Parser::DeclGroupPtrTy Parser::ParseSimpleDeclaration(unsigned Context,
SourceLocation &DeclEnd,
- AttributeList *Attr) {
+ AttributeList *Attr,
+ bool RequireSemi) {
// Parse the common declaration-specifiers piece.
ParsingDeclSpec DS(*this);
if (Attr)
@@ -362,15 +363,13 @@
// C99 6.7.2.3p6: Handle "struct-or-union identifier;", "enum { X };"
// declaration-specifiers init-declarator-list[opt] ';'
if (Tok.is(tok::semi)) {
- ConsumeToken();
+ if (RequireSemi) ConsumeToken();
DeclPtrTy TheDecl = Actions.ParsedFreeStandingDeclSpec(CurScope, DS);
DS.complete(TheDecl);
return Actions.ConvertDeclToDeclGroup(TheDecl);
}
- DeclGroupPtrTy DG = ParseDeclGroup(DS, Context, /*FunctionDefs=*/ false,
- &DeclEnd);
- return DG;
+ return ParseDeclGroup(DS, Context, /*FunctionDefs=*/ false, &DeclEnd);
}
/// ParseDeclGroup - Having concluded that this is either a function
@@ -999,6 +998,10 @@
DiagID, Tok.getAnnotationValue());
else
DS.SetTypeSpecError();
+
+ if (isInvalid)
+ break;
+
DS.SetRangeEnd(Tok.getAnnotationEndLoc());
ConsumeToken(); // The typename
Modified: cfe/trunk/lib/Parse/ParseStmt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseStmt.cpp?rev=100443&r1=100442&r2=100443&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseStmt.cpp (original)
+++ cfe/trunk/lib/Parse/ParseStmt.cpp Mon Apr 5 13:18:31 2010
@@ -997,7 +997,7 @@
SourceLocation DeclStart = Tok.getLocation(), DeclEnd;
DeclGroupPtrTy DG = ParseSimpleDeclaration(Declarator::ForContext, DeclEnd,
- AttrList);
+ AttrList, false);
FirstPart = Actions.ActOnDeclStmt(DG, DeclStart, Tok.getLocation());
if (Tok.is(tok::semi)) { // for (int x = 4;
Modified: cfe/trunk/test/Parser/cxx-decl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/cxx-decl.cpp?rev=100443&r1=100442&r2=100443&view=diff
==============================================================================
--- cfe/trunk/test/Parser/cxx-decl.cpp (original)
+++ cfe/trunk/test/Parser/cxx-decl.cpp Mon Apr 5 13:18:31 2010
@@ -62,3 +62,13 @@
// PR5825
struct test5 {};
::new(static_cast<void*>(0)) test5; // expected-error {{expected unqualified-id}}
+
+
+// PR6782
+template<class T>
+class Class1;
+
+class Class2 {
+} // no ;
+
+typedef Class1<Class2> Type1; // expected-error {{cannot combine with previous 'class' declaration specifier}}
More information about the cfe-commits
mailing list