diff options
Diffstat (limited to 'clang/lib')
-rw-r--r-- | clang/lib/Parse/ParseStmt.cpp | 26 | ||||
-rw-r--r-- | clang/lib/Parse/Parser.cpp | 9 | ||||
-rw-r--r-- | clang/lib/Sema/Scope.cpp | 37 |
3 files changed, 0 insertions, 72 deletions
diff --git a/clang/lib/Parse/ParseStmt.cpp b/clang/lib/Parse/ParseStmt.cpp index fe884148ebe..f57ff97ceb5 100644 --- a/clang/lib/Parse/ParseStmt.cpp +++ b/clang/lib/Parse/ParseStmt.cpp @@ -1135,9 +1135,6 @@ StmtResult Parser::ParseSwitchStatement(SourceLocation *TrailingElseLoc) { ScopeFlags |= Scope::DeclScope | Scope::ControlScope; ParseScope SwitchScope(this, ScopeFlags); - // Temporarily disable 'break' while parsing condition. - SwitchScope.ClearFlags(Scope::BreakScope); - // Parse the condition. ExprResult Cond; Decl *CondVar = 0; @@ -1160,9 +1157,6 @@ StmtResult Parser::ParseSwitchStatement(SourceLocation *TrailingElseLoc) { return Switch; } - // Enable 'break' in the body of switch statement. - SwitchScope.SetFlags(Scope::BreakScope); - // 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. We only do this // if the body isn't a compound statement to avoid push/pop in common cases. @@ -1233,9 +1227,6 @@ StmtResult Parser::ParseWhileStatement(SourceLocation *TrailingElseLoc) { ScopeFlags = Scope::BreakScope | Scope::ContinueScope; ParseScope WhileScope(this, ScopeFlags); - // Disable 'break' and 'continue' while parsing condition. - WhileScope.ClearFlags(Scope::BreakScope | Scope::ContinueScope); - // Parse the condition. ExprResult Cond; Decl *CondVar = 0; @@ -1244,9 +1235,6 @@ StmtResult Parser::ParseWhileStatement(SourceLocation *TrailingElseLoc) { FullExprArg FullCond(Actions.MakeFullExpr(Cond.get(), WhileLoc)); - // Allow 'break' and 'continue' in the body of the statement. - WhileScope.SetFlags(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. We only do this // if the body isn't a compound statement to avoid push/pop in common cases. @@ -1326,9 +1314,6 @@ StmtResult Parser::ParseDoStatement() { return StmtError(); } - // Do not allow 'break' and 'continue' in 'while' condition expression. - DoScope.ClearFlags(Scope::BreakScope | Scope::ContinueScope); - // Parse the parenthesized expression. BalancedDelimiterTracker T(*this, tok::l_paren); T.consumeOpen(); @@ -1406,10 +1391,6 @@ StmtResult Parser::ParseForStatement(SourceLocation *TrailingElseLoc) { BalancedDelimiterTracker T(*this, tok::l_paren); T.consumeOpen(); - // Until loop body starts, statements 'break' and 'continue' cannot - // be used. - ForScope.ClearFlags(Scope::BreakScope | Scope::ContinueScope); - ExprResult Value; bool ForEach = false, ForRange = false; @@ -1553,10 +1534,6 @@ StmtResult Parser::ParseForStatement(SourceLocation *TrailingElseLoc) { // Parse the third part of the for specifier. if (Tok.isNot(tok::r_paren)) { // for (...;...;) - // This is needed to compile QT 4.8.4, which uses statement - // expression with 'break' in it. - ForScope.SetFlags(Scope::BreakScope); - ExprResult Third = ParseExpression(); // FIXME: The C++11 standard doesn't actually say that this is a // discarded-value expression, but it clearly should be. @@ -1589,9 +1566,6 @@ StmtResult Parser::ParseForStatement(SourceLocation *TrailingElseLoc) { T.getCloseLocation()); } - // When parsing body of 'for' statement, 'break' and 'continue' may be used. - ForScope.SetFlags(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. We only do this // if the body isn't a compound statement to avoid push/pop in common cases. diff --git a/clang/lib/Parse/Parser.cpp b/clang/lib/Parse/Parser.cpp index 2e1ace53ea8..9b6c97ac195 100644 --- a/clang/lib/Parse/Parser.cpp +++ b/clang/lib/Parse/Parser.cpp @@ -390,15 +390,6 @@ void Parser::ExitScope() { ScopeCache[NumCachedScopes++] = OldScope; } -void Parser::SetScopeFlags(unsigned Flags) { - Actions.CurScope->SetFlags(Flags); -} - -void Parser::ClearScopeFlags(unsigned Flags) { - Actions.CurScope->ClearFlags(Flags); -} - - /// Set the flags for the current scope to ScopeFlags. If ManageFlags is false, /// this object does nothing. Parser::ParseScopeFlags::ParseScopeFlags(Parser *Self, unsigned ScopeFlags, diff --git a/clang/lib/Sema/Scope.cpp b/clang/lib/Sema/Scope.cpp index 8c2a8b37735..10f12ce844f 100644 --- a/clang/lib/Sema/Scope.cpp +++ b/clang/lib/Sema/Scope.cpp @@ -69,40 +69,3 @@ bool Scope::containedInPrototypeScope() const { } return false; } - -void Scope::SetFlags(unsigned FlagsToSet) { - assert((FlagsToSet & ~(BreakScope | ContinueScope)) == 0 || - "Unsupported scope flags"); - assert ((Flags & ControlScope) != 0 || "Must be control scope"); - if (FlagsToSet & BreakScope) { - assert((Flags & BreakScope) == 0 || "Already set"); - BreakParent = this; - } - if (FlagsToSet & ContinueScope) { - assert((Flags & ContinueScope) == 0 || "Already set"); - ContinueParent = this; - } - Flags |= FlagsToSet; -} - -void Scope::ClearFlags(unsigned FlagsToClear) { - assert((FlagsToClear & ~(BreakScope | ContinueScope)) == 0 || - "Unsupported scope flags"); - if (FlagsToClear & BreakScope) { - assert((Flags & ControlScope) != 0 || "Must be control scope"); - assert((Flags & BreakScope) != 0 || "Already cleared"); - // This is a loop or switch scope. Flag BreakScope is removed temporarily - // when parsing the loop or switch header, to prevent constructs like this: - // \code - // while (({ if(a>N) break; a})) - // \endcode - BreakParent = 0; - } - if (FlagsToClear & ContinueScope) { - assert ((Flags & ControlScope) != 0 || "Must be control scope"); - assert((Flags & ContinueScope) != 0 || "Already cleared"); - ContinueParent = 0; - } - Flags &= ~FlagsToClear; -} - |