[cfe-commits] r38819 - /cfe/cfe/trunk/Parse/Parser.cpp
sabre at cs.uiuc.edu
sabre at cs.uiuc.edu
Wed Jul 11 09:24:55 PDT 2007
Author: sabre
Date: Wed Jul 11 11:24:54 2007
New Revision: 38819
URL: http://llvm.org/viewvc/llvm-project?rev=38819&view=rev
Log:
Make error recovery "better"
Modified:
cfe/cfe/trunk/Parse/Parser.cpp
Modified: cfe/cfe/trunk/Parse/Parser.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/cfe/trunk/Parse/Parser.cpp?rev=38819&r1=38818&r2=38819&view=diff
==============================================================================
--- cfe/cfe/trunk/Parse/Parser.cpp (original)
+++ cfe/cfe/trunk/Parse/Parser.cpp Wed Jul 11 11:24:54 2007
@@ -92,10 +92,16 @@
// NOTE: this can not be missing for C99 'declaration's.
DeclSpec DS;
ParseDeclarationSpecifiers(DS);
+
+ // C99 6.7.2.3p6: Handle "struct-or-union identifier;", "enum { X };"
+ if (Tok.getKind() == tok::semi)
+ assert(0 && "Unimp!");
+
// Parse the common declarator piece.
ParseDeclarator();
+
// If the declarator was a function type... handle it.
// must be: decl-spec[opt] declarator init-declarator-list
@@ -103,13 +109,7 @@
if (Tok.getKind() == tok::equal)
assert(0 && "cannot handle initializer yet!");
- while (Tok.getKind() != tok::semi) {
- if (Tok.getKind() != tok::comma && Tok.getKind() != tok::semi) {
- // FIXME: skip toe nd of block or statement
- Diag(Tok, diag::err_parse_error);
- ConsumeToken();
- }
-
+ while (Tok.getKind() == tok::comma) {
// Consume the comma.
ConsumeToken();
@@ -122,13 +122,16 @@
}
- switch (Tok.getKind()) {
- case tok::comma: // must be: decl-spec[opt] declarator init-declarator-list
- default:
- assert(0 && "unimp!");
- case tok::semi:
+
+ if (Tok.getKind() == tok::semi) {
ConsumeToken();
- break;
+ } else {
+ Diag(Tok, diag::err_parse_error);
+ // FIXME: skip to end of block or statement
+ while (Tok.getKind() != tok::semi && Tok.getKind() != tok::eof)
+ ConsumeToken();
+ if (Tok.getKind() == tok::semi)
+ ConsumeToken();
}
}
More information about the cfe-commits
mailing list