[cfe-commits] r41264 - /cfe/trunk/Parse/ParseStmt.cpp
Chris Lattner
sabre at nondot.org
Tue Aug 21 22:28:51 PDT 2007
Author: lattner
Date: Wed Aug 22 00:28:50 2007
New Revision: 41264
URL: http://llvm.org/viewvc/llvm-project?rev=41264&view=rev
Log:
Fix the scoping issue Neil pointed out for the rest of
the selection statements and iteration statements. Add
spec citations.
Modified:
cfe/trunk/Parse/ParseStmt.cpp
Modified: cfe/trunk/Parse/ParseStmt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Parse/ParseStmt.cpp?rev=41264&r1=41263&r2=41264&view=diff
==============================================================================
--- cfe/trunk/Parse/ParseStmt.cpp (original)
+++ cfe/trunk/Parse/ParseStmt.cpp Wed Aug 22 00:28:50 2007
@@ -433,8 +433,8 @@
return true;
}
- // In C99, the body of the if statement is a scope, even if there is no
- // compound stmt.
+ // C99 6.8.4p3 - In C99, the body of the if statement is a scope, even if
+ // there is no compound stmt. C90 does not have this clause.
if (getLang().C99) EnterScope(0);
// Read the if condition.
@@ -453,8 +453,8 @@
if (Tok.getKind() == tok::kw_else) {
ElseLoc = ConsumeToken();
- // In C99, the body of the if statement is a scope, even if there is no
- // compound stmt.
+ // C99 6.8.4p3 - In C99, the body of the if statement is a scope, even if
+ // there is no compound stmt. C90 does not have this clause.
if (getLang().C99) EnterScope(0);
ElseStmt = ParseStatement();
@@ -496,9 +496,16 @@
StmtResult Switch = Actions.StartSwitchStmt(Cond.Val);
+ // C99 6.8.4p3 - In C99, the body of the switch statement is a scope, even if
+ // there is no compound stmt. C90 does not have this clause.
+ if (getLang().C99) EnterScope(0);
+
// Read the body statement.
StmtResult Body = ParseStatement();
+ // Pop the body scope if needed.
+ if (getLang().C99) ExitScope();
+
if (Body.isInvalid) {
Body = Actions.ParseNullStmt(Tok.getLocation());
// FIXME: Remove the case statement list from the Switch statement.
@@ -529,9 +536,16 @@
// Parse the condition.
ExprResult Cond = ParseSimpleParenExpression();
+ // 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.
+ if (getLang().C99) EnterScope(0);
+
// Read the body statement.
StmtResult Body = ParseStatement();
+ // Pop the body scope if needed.
+ if (getLang().C99) ExitScope();
+
ExitScope();
if (Cond.isInvalid || Body.isInvalid) return true;
@@ -550,9 +564,16 @@
// Start the loop scope.
EnterScope(Scope::BreakScope | Scope::ContinueScope);
+ // 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.
+ if (getLang().C99) EnterScope(0);
+
// Read the body statement.
StmtResult Body = ParseStatement();
+ // Pop the body scope if needed.
+ if (getLang().C99) ExitScope();
+
if (Tok.getKind() != tok::kw_while) {
ExitScope();
Diag(Tok, diag::err_expected_while);
@@ -665,9 +686,16 @@
// Match the ')'.
SourceLocation RParenLoc = MatchRHSPunctuation(tok::r_paren, LParenLoc);
+ // 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.
+ if (getLang().C99) EnterScope(0);
+
// Read the body statement.
StmtResult Body = ParseStatement();
+ // Pop the body scope if needed.
+ if (getLang().C99) ExitScope();
+
// Leave the for-scope.
ExitScope();
More information about the cfe-commits
mailing list