Added a warning when referencing an if's condition variable in the
"else" clause, e.g.,

  if (int X = foo()) {
  } else {
    if (X) { // warning: X is always zero in this context
    }
  }

Fixes rdar://6425550 and lets me think about something other than
DeclContext.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@60858 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Parse/ParseStmt.cpp b/lib/Parse/ParseStmt.cpp
index 8b5277b..cb35740 100644
--- a/lib/Parse/ParseStmt.cpp
+++ b/lib/Parse/ParseStmt.cpp
@@ -509,8 +509,11 @@
     ParseScope InnerScope(this, Scope::DeclScope, 
                           C99orCXX && Tok.isNot(tok::l_brace));
 
+    bool WithinElse = CurScope->isWithinElse();
+    CurScope->setWithinElse(true);
     ElseStmtLoc = Tok.getLocation();
     ElseStmt = ParseStatement();
+    CurScope->setWithinElse(WithinElse);
 
     // Pop the 'else' scope if needed.
     InnerScope.Exit();