diff options
| author | Chris Lattner <sabre@nondot.org> | 2007-08-28 05:03:08 +0000 |
|---|---|---|
| committer | Chris Lattner <sabre@nondot.org> | 2007-08-28 05:03:08 +0000 |
| commit | 39f920f35b98f956acf03652ba244608e48807dd (patch) | |
| tree | e5f6e6c37cc0f850d30b2885d9b7ecc1ae967c2b /clang/Sema/SemaStmt.cpp | |
| parent | 773c0596b89540e609c2b9e9a1143c3c6ccb43e6 (diff) | |
| download | bcm5719-llvm-39f920f35b98f956acf03652ba244608e48807dd.tar.gz bcm5719-llvm-39f920f35b98f956acf03652ba244608e48807dd.zip | |
now that all the infrastructure is in place, enforce C99 6.8.5p3.
Note the FIXME: we need some way to mark a decl erroneous :)
llvm-svn: 41524
Diffstat (limited to 'clang/Sema/SemaStmt.cpp')
| -rw-r--r-- | clang/Sema/SemaStmt.cpp | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/clang/Sema/SemaStmt.cpp b/clang/Sema/SemaStmt.cpp index 5b4be815c0e..6247215f0ed 100644 --- a/clang/Sema/SemaStmt.cpp +++ b/clang/Sema/SemaStmt.cpp @@ -453,10 +453,17 @@ Sema::ParseForStmt(SourceLocation ForLoc, SourceLocation LParenLoc, 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 (DeclStmt *DS = dyn_cast_or_null<DeclStmt>(First)) { + // C99 6.8.5p3: The declaration part of a 'for' statement shall only declare + // identifiers for objects having storage class 'auto' or 'register'. + for (Decl *D = DS->getDecl(); D; D = D->getNextDeclarator()) { + BlockVarDecl *BVD = dyn_cast<BlockVarDecl>(D); + if (BVD && !BVD->hasLocalStorage()) + BVD = 0; + if (BVD == 0) + Diag(D->getLocation(), diag::err_non_variable_decl_in_for); + // FIXME: mark decl erroneous! + } } if (Second) { DefaultFunctionArrayConversion(Second); |

