Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(44)

Unified Diff: tools/gn/parser.cc

Issue 996893002: gn: Enforce braces after 'else' (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | tools/gn/parser_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/gn/parser.cc
diff --git a/tools/gn/parser.cc b/tools/gn/parser.cc
index d99b574c073cb9776066d638c83f1414d0800c49..4acd510328b0e3dd5df631036dfc6b26af25aa66 100644
--- a/tools/gn/parser.cc
+++ b/tools/gn/parser.cc
@@ -499,8 +499,13 @@ scoped_ptr<ParseNode> Parser::ParseCondition() {
*err_ = Err(condition->condition(), "Assignment not allowed in 'if'.");
Consume(Token::RIGHT_PAREN, "Expected ')' after condition of 'if'.");
condition->set_if_true(ParseBlock().Pass());
- if (Match(Token::ELSE))
+ if (Match(Token::ELSE)) {
+ if (!LookAhead(Token::LEFT_BRACE) && !LookAhead(Token::IF)) {
tfarina 2015/03/10 20:37:24 || here does the wrong thing? Anyway, thanks for
scottmg 2015/03/10 21:21:00 I'm not sure what you mean. Right now it says "if
+ *err_ = Err(cur_token(), "Expected '{' or 'if' after 'else'.");
+ return scoped_ptr<ParseNode>();
tfarina 2015/03/10 20:37:24 This can be return nullptr;
scottmg 2015/03/10 21:21:00 There's a whole bunch that predate nullptr in this
+ }
condition->set_if_false(ParseStatement().Pass());
+ }
if (has_error())
return scoped_ptr<ParseNode>();
return condition.Pass();
« no previous file with comments | « no previous file | tools/gn/parser_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698