aboutsummaryrefslogtreecommitdiff
path: root/lib/Parse/ParseInit.cpp
diff options
context:
space:
mode:
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>2008-07-09 22:53:07 +0000
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>2008-07-09 22:53:07 +0000
commitf7da726f09a6b7c5b9f5308e9690cb015398e671 (patch)
tree5ad8b5e569574f0626a77cc6be84b9c88a0e5e72 /lib/Parse/ParseInit.cpp
parent9e0ed0bd5a3a7bac73973980ff32132a7724e674 (diff)
Simplify the parser a bit by looking at the next token without consuming it (by Preprocessor::LookNext):
-Remove ParseExpressionWithLeadingIdentifier and ParseAssignmentExprWithLeadingIdentifier. -Separate ParseLabeledStatement from ParseIdentifierStatement. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@53376 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Parse/ParseInit.cpp')
-rw-r--r--lib/Parse/ParseInit.cpp13
1 files changed, 6 insertions, 7 deletions
diff --git a/lib/Parse/ParseInit.cpp b/lib/Parse/ParseInit.cpp
index a1fe04b731..c7c08dccbc 100644
--- a/lib/Parse/ParseInit.cpp
+++ b/lib/Parse/ParseInit.cpp
@@ -142,19 +142,18 @@ Parser::ExprResult Parser::ParseInitializerWithPotentialDesignator() {
// assignment-expression or if it is an old-style structure field
// designator.
// TODO: Check that this is the first designator.
- Token Ident = Tok;
- ConsumeToken();
// If this is the gross GNU extension, handle it now.
- if (Tok.is(tok::colon)) {
- Diag(Ident, diag::ext_gnu_old_style_field_designator);
+ if (NextToken().is(tok::colon)) {
+ Diag(Tok, diag::ext_gnu_old_style_field_designator);
+ ConsumeToken(); // The identifier.
+ assert(Tok.is(tok::colon) && "NextToken() not working properly!");
ConsumeToken();
return ParseInitializer();
}
- // Otherwise, we just consumed the first token of an expression. Parse
- // the rest of it now.
- return ParseAssignmentExprWithLeadingIdentifier(Ident);
+ // Otherwise, parse the assignment-expression.
+ return ParseAssignmentExpression();
}
}
}