aboutsummaryrefslogtreecommitdiff
path: root/lib/Parse/ParseStmt.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2010-04-12 06:12:50 +0000
committerChris Lattner <sabre@nondot.org>2010-04-12 06:12:50 +0000
commit966c78b79004061c1f64feff96818b9f1d68ea58 (patch)
tree37a37c7048ddffa186ee50a7bde3e344afb078f0 /lib/Parse/ParseStmt.cpp
parentcf7cfe874c251b132401ccc46173ec20d5d84cf2 (diff)
change Scope::WithinElse to be a normal scope flag, widen the
fields to two 16-bit values instead of using bitfields. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@101020 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Parse/ParseStmt.cpp')
-rw-r--r--lib/Parse/ParseStmt.cpp13
1 files changed, 8 insertions, 5 deletions
diff --git a/lib/Parse/ParseStmt.cpp b/lib/Parse/ParseStmt.cpp
index b208c50c81..9b2227002f 100644
--- a/lib/Parse/ParseStmt.cpp
+++ b/lib/Parse/ParseStmt.cpp
@@ -643,6 +643,7 @@ Parser::OwningStmtResult Parser::ParseIfStatement(AttributeList *Attr) {
if (Tok.is(tok::kw_else)) {
ElseLoc = ConsumeToken();
+ ElseStmtLoc = Tok.getLocation();
// 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. We only do
@@ -656,12 +657,14 @@ Parser::OwningStmtResult Parser::ParseIfStatement(AttributeList *Attr) {
ParseScope InnerScope(this, Scope::DeclScope,
C99orCXX && Tok.isNot(tok::l_brace));
- bool WithinElse = CurScope->isWithinElse();
- CurScope->setWithinElse(true);
- ElseStmtLoc = Tok.getLocation();
+ // Regardless of whether or not InnerScope actually pushed a scope, set the
+ // ElseScope flag for the innermost scope so we can diagnose use of the if
+ // condition variable in C++.
+ unsigned OldFlags = CurScope->getFlags();
+ CurScope->setFlags(OldFlags | Scope::ElseScope);
ElseStmt = ParseStatement();
- CurScope->setWithinElse(WithinElse);
-
+ CurScope->setFlags(OldFlags);
+
// Pop the 'else' scope if needed.
InnerScope.Exit();
}