[cfe-commits] r38853 - in /cfe/cfe/trunk: Parse/ParseStmt.cpp test/Parser/statements.c
sabre at cs.uiuc.edu
sabre at cs.uiuc.edu
Wed Jul 11 09:25:12 PDT 2007
Author: sabre
Date: Wed Jul 11 11:25:12 2007
New Revision: 38853
URL: http://llvm.org/viewvc/llvm-project?rev=38853&view=rev
Log:
Add support for simple labels.
Modified:
cfe/cfe/trunk/Parse/ParseStmt.cpp
cfe/cfe/trunk/test/Parser/statements.c
Modified: cfe/cfe/trunk/Parse/ParseStmt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/cfe/trunk/Parse/ParseStmt.cpp?rev=38853&r1=38852&r2=38853&view=diff
==============================================================================
--- cfe/cfe/trunk/Parse/ParseStmt.cpp (original)
+++ cfe/cfe/trunk/Parse/ParseStmt.cpp Wed Jul 11 11:25:12 2007
@@ -169,10 +169,33 @@
/// there is a ':' after it. If there is, this is a label, regardless of what
/// else the identifier can mean. If not, this is either part of a declaration
/// (if the identifier is a type-name) or part of an expression.
+///
+/// labeled-statement:
+/// identifier ':' statement
+/// declaration (if !OnlyStatement)
+/// expression[opt] ';'
+///
void Parser::ParseIdentifierStatement(bool OnlyStatement) {
+ IdentifierInfo *II = Tok.getIdentifierInfo();
+ assert(Tok.getKind() == tok::identifier && II && "Not an identifier!");
+
+ ConsumeToken(); // eat the identifier.
- assert(0);
+ // identifier ':' statement
+ if (Tok.getKind() == tok::colon) {
+ ConsumeToken();
+ ParseStatement();
+ return;
+ }
+ // declaration
+ if (!OnlyStatement && 0/*Is typedef name!*/) {
+ // Handle this. Warn/disable if in middle of block and !C99.
+ }
+
+ // Otherwise, this is an expression.
+
+ assert(0);
}
/// ParseCaseStatement
Modified: cfe/cfe/trunk/test/Parser/statements.c
URL: http://llvm.org/viewvc/llvm-project/cfe/cfe/trunk/test/Parser/statements.c?rev=38853&r1=38852&r2=38853&view=diff
==============================================================================
--- cfe/cfe/trunk/test/Parser/statements.c (original)
+++ cfe/cfe/trunk/test/Parser/statements.c Wed Jul 11 11:25:12 2007
@@ -35,5 +35,5 @@
int X; // declaration in a block.
- if (0);
+foo: if (0);
}
More information about the cfe-commits
mailing list