Commit 9991b626 authored by Tobias Tebbi's avatar Tobias Tebbi Committed by Commit Bot

[torque] forbid brace-free if-else

Bug: v8:8012 v8:7793
Change-Id: Idc5d685d021fd107974b4415f7b855397004cb53
Reviewed-on: https://chromium-review.googlesource.com/1160841Reviewed-by: 's avatarCamillo Bruni <cbruni@chromium.org>
Commit-Queue: Tobias Tebbi <tebbi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#54893}
parent 842569eb
......@@ -456,6 +456,13 @@ base::Optional<ParseResult> MakeIfStatement(
auto condition = child_results->NextAs<Expression*>();
auto if_true = child_results->NextAs<Statement*>();
auto if_false = child_results->NextAs<base::Optional<Statement*>>();
if (if_false && !(BlockStatement::DynamicCast(if_true) &&
(BlockStatement::DynamicCast(*if_false) ||
IfStatement::DynamicCast(*if_false)))) {
ReportError("if-else statements require curly braces");
}
Statement* result =
MakeNode<IfStatement>(is_constexpr, condition, if_true, if_false);
return ParseResult{result};
......
......@@ -98,10 +98,11 @@ module test {
}
macro LabelTestHelper4(flag: constexpr bool): never labels Label4, Label5 {
if
constexpr(flag) goto Label4;
else
if constexpr(flag) {
goto Label4;
} else {
goto Label5;
}
}
macro CallLabelTestHelper4(flag: constexpr bool): bool {
......@@ -120,10 +121,11 @@ module test {
let r1: bool = CallLabelTestHelper4(true);
let r2: bool = CallLabelTestHelper4(false);
if (r1 && !r2)
if (r1 && !r2) {
return True;
else
} else {
return False;
}
}
macro GenericMacroTest<T : type>(param: T): Object {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment