summaryrefslogtreecommitdiffstats
path: root/clang
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2007-08-28 04:55:47 +0000
committerChris Lattner <sabre@nondot.org>2007-08-28 04:55:47 +0000
commit773c0596b89540e609c2b9e9a1143c3c6ccb43e6 (patch)
tree0c7fe67cf23b3566eada5259468bc79dc54aee52 /clang
parent0e258b8518926bc83f99ea9556b790d94f4130b4 (diff)
downloadbcm5719-llvm-773c0596b89540e609c2b9e9a1143c3c6ccb43e6.tar.gz
bcm5719-llvm-773c0596b89540e609c2b9e9a1143c3c6ccb43e6.zip
If the condition of a for statement is promoted, make sure the
implicit cast gets linked back into the AST. llvm-svn: 41523
Diffstat (limited to 'clang')
-rw-r--r--clang/Sema/SemaStmt.cpp20
1 files changed, 12 insertions, 8 deletions
diff --git a/clang/Sema/SemaStmt.cpp b/clang/Sema/SemaStmt.cpp
index f4c54147778..5b4be815c0e 100644
--- a/clang/Sema/SemaStmt.cpp
+++ b/clang/Sema/SemaStmt.cpp
@@ -446,23 +446,27 @@ Sema::ParseDoStmt(SourceLocation DoLoc, StmtTy *Body,
Action::StmtResult
Sema::ParseForStmt(SourceLocation ForLoc, SourceLocation LParenLoc,
- StmtTy *First, ExprTy *Second, ExprTy *Third,
- SourceLocation RParenLoc, StmtTy *Body) {
+ StmtTy *first, ExprTy *second, ExprTy *third,
+ SourceLocation RParenLoc, StmtTy *body) {
+ Stmt *First = static_cast<Stmt*>(first);
+ Expr *Second = static_cast<Expr*>(second);
+ Expr *Third = static_cast<Expr*>(third);
+ Stmt *Body = static_cast<Stmt*>(body);
+
if (First) {
// C99 6.8.5p3: FIXME. Need to hack Parser::ParseForStatement() and
// declaration support to create a DeclStmt node. Once this is done,
// we can test for DeclStmt vs. Expr (already a sub-class of Stmt).
}
if (Second) {
- Expr *testExpr = (Expr *)Second;
- DefaultFunctionArrayConversion(testExpr);
- QualType testType = testExpr->getType();
+ DefaultFunctionArrayConversion(Second);
+ QualType SecondType = Second->getType();
- if (!testType->isScalarType()) // C99 6.8.5p2
+ if (!SecondType->isScalarType()) // C99 6.8.5p2
return Diag(ForLoc, diag::err_typecheck_statement_requires_scalar,
- testType.getAsString(), testExpr->getSourceRange());
+ SecondType.getAsString(), Second->getSourceRange());
}
- return new ForStmt((Stmt*)First, (Expr*)Second, (Expr*)Third, (Stmt*)Body);
+ return new ForStmt(First, Second, Third, Body);
}
OpenPOWER on IntegriCloud