Add support for simple labels.

llvm-svn: 38853
This commit is contained in:
Chris Lattner 2006-08-10 18:31:37 +00:00
parent f8afb62ef9
commit 6dfd97806e
2 changed files with 25 additions and 2 deletions

View File

@ -169,10 +169,33 @@ ParseNextStatement:
/// 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.
// 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

View File

@ -35,5 +35,5 @@ int test4() {
int X; // declaration in a block.
if (0);
foo: if (0);
}