diff options
author | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2008-09-11 04:46:46 +0000 |
---|---|---|
committer | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2008-09-11 04:46:46 +0000 |
commit | fea38016a92ea2afc6ab1b87ffeaac3f3aa03fe7 (patch) | |
tree | eed25ec6dfaf5e36213355b58c44f2bbcbb6c612 /clang/lib/Parse/ParseStmt.cpp | |
parent | 9321c74bd029e95653bdb01ca18396a21e919e51 (diff) | |
download | bcm5719-llvm-fea38016a92ea2afc6ab1b87ffeaac3f3aa03fe7.tar.gz bcm5719-llvm-fea38016a92ea2afc6ab1b87ffeaac3f3aa03fe7.zip |
Fix do-while scoping in C++.
llvm-svn: 56095
Diffstat (limited to 'clang/lib/Parse/ParseStmt.cpp')
-rw-r--r-- | clang/lib/Parse/ParseStmt.cpp | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/clang/lib/Parse/ParseStmt.cpp b/clang/lib/Parse/ParseStmt.cpp index 875634daa67..c776bb6c15a 100644 --- a/clang/lib/Parse/ParseStmt.cpp +++ b/clang/lib/Parse/ParseStmt.cpp @@ -702,7 +702,13 @@ Parser::StmtResult Parser::ParseDoStatement() { // C99 6.8.5p5 - In C99, the body of the if statement is a scope, even if // there is no compound stmt. C90 does not have this clause. We only do this // if the body isn't a compound statement to avoid push/pop in common cases. - bool NeedsInnerScope = getLang().C99 && Tok.isNot(tok::l_brace); + // + // C++ 6.5p2: + // The substatement in an iteration-statement implicitly defines a local scope + // which is entered and exited each time through the loop. + // + bool NeedsInnerScope = (getLang().C99 || getLang().CPlusPlus) && + Tok.isNot(tok::l_brace); if (NeedsInnerScope) EnterScope(Scope::DeclScope); // Read the body statement. |