Bug #:
Submitted by:
Reviewed by:
Implement some FIXME's that stand in the way of fully typechecking "for"
statements. This involved:
- Adding a DeclStmt AST node (with statement visitor). The DeclStmt
printer is preliminary.
- Added a ParseDeclStmt action, called from Parser::ParseForStatement()
and Parser::ParseStatementOrDeclaration(). DID NOT add to
Parser::ParseIdentifierStatement()...probably could have, however didn't
really understand the context of this rule (will speak with Chris).
- Removed ParseExprStmt (and it's clients)...it was vestigial.
llvm-svn: 39518
diff --git a/clang/Parse/ParseStmt.cpp b/clang/Parse/ParseStmt.cpp
index b1c04f6..32b8a98 100644
--- a/clang/Parse/ParseStmt.cpp
+++ b/clang/Parse/ParseStmt.cpp
@@ -86,9 +86,7 @@
default:
if (!OnlyStatement && isDeclarationSpecifier()) {
// TODO: warn/disable if declaration is in the middle of a block and !C99.
- ParseDeclaration(Declarator::BlockContext);
- // FIXME: Make a DeclStmt node!
- return 0;
+ return Actions.ParseDeclStmt(ParseDeclaration(Declarator::BlockContext));
} else if (Tok.getKind() == tok::r_brace) {
Diag(Tok, diag::err_expected_statement);
return true;
@@ -102,7 +100,7 @@
SkipUntil(tok::semi);
return true;
} else {
- return Actions.ParseExprStmt(Res.Val);
+ return Res.Val;
}
}
@@ -250,7 +248,7 @@
return true;
} else {
ConsumeToken();
- return Actions.ParseExprStmt(Res.Val);
+ return Res.Val;
}
}
@@ -586,19 +584,12 @@
// Parse declaration, which eats the ';'.
if (!getLang().C99) // Use of C99-style for loops in C90 mode?
Diag(Tok, diag::ext_c99_variable_decl_in_for_loop);
- ParseDeclaration(Declarator::ForContext);
- // FIXME: Turn declaration into a stmt ast node.
- FirstPart = 0;
+ DeclTy *aBlockVarDecl = ParseDeclaration(Declarator::ForContext);
+ StmtResult stmtResult = Actions.ParseDeclStmt(aBlockVarDecl);
+ FirstPart = stmtResult.isInvalid ? 0 : stmtResult.Val;
} else {
Value = ParseExpression();
- // Turn the expression into a stmt.
- if (!Value.isInvalid) {
- StmtResult R = Actions.ParseExprStmt(Value.Val);
- if (!R.isInvalid)
- FirstPart = R.Val;
- }
-
if (Tok.getKind() == tok::semi) {
ConsumeToken();
} else {