validation: Error on obviously infinite loops

Most of this change is fixing up the numerious tests that violated this rule.

Fixed: tint:1365
Issue: tint:1374
Change-Id: I38da27c7367277fe60857208170fec017e80bd25
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/76400
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: David Neto <dneto@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
This commit is contained in:
Ben Clayton 2022-01-14 17:16:32 +00:00 committed by Tint LUCI CQ
parent 8dd9a56f91
commit e5919ac115
233 changed files with 3562 additions and 1422 deletions

View File

@ -2,6 +2,10 @@
## Changes for M99
### Breaking changes
Obviously infinite loops (no condition, no break) are now a validation error.
### Deprecated Features
The following features have been deprecated and will be removed in M102:

View File

@ -82,15 +82,15 @@ TEST_F(ResolverCompoundStatementTest, Block) {
TEST_F(ResolverCompoundStatementTest, Loop) {
// fn F() {
// loop {
// stmt_a;
// break;
// continuing {
// stmt_b;
// stmt;
// }
// }
// }
auto* stmt_a = Ignore(1);
auto* stmt_b = Ignore(1);
auto* loop = Loop(Block(stmt_a), Block(stmt_b));
auto* brk = Break();
auto* stmt = Ignore(1);
auto* loop = Loop(Block(brk), Block(stmt));
auto* f = Func("F", {}, ty.void_(), {loop});
ASSERT_TRUE(r()->Resolve()) << r()->error();
@ -103,7 +103,7 @@ TEST_F(ResolverCompoundStatementTest, Loop) {
EXPECT_EQ(s->Parent(), s->Block());
}
{
auto* s = Sem().Get(stmt_a);
auto* s = Sem().Get(brk);
ASSERT_NE(s, nullptr);
ASSERT_NE(s->Block(), nullptr);
EXPECT_EQ(s->Parent(), s->Block());
@ -122,7 +122,7 @@ TEST_F(ResolverCompoundStatementTest, Loop) {
EXPECT_EQ(s->Parent()->Parent()->Parent()->Parent(), nullptr);
}
{
auto* s = Sem().Get(stmt_b);
auto* s = Sem().Get(stmt);
ASSERT_NE(s, nullptr);
ASSERT_NE(s->Block(), nullptr);
EXPECT_EQ(s->Parent(), s->Block());

View File

@ -86,6 +86,7 @@ TEST_F(ResolverControlBlockValidationTest, SwitchWithTwoDefault_Fail) {
TEST_F(ResolverControlBlockValidationTest, UnreachableCode_Loop_continue) {
// loop {
// if (false) { break; }
// var z: i32;
// continue;
// z = 1;
@ -93,7 +94,8 @@ TEST_F(ResolverControlBlockValidationTest, UnreachableCode_Loop_continue) {
auto* decl_z = Decl(Var("z", ty.i32()));
auto* cont = Continue();
auto* assign_z = Assign(Source{{12, 34}}, "z", 1);
WrapInFunction(Loop(Block(decl_z, cont, assign_z)));
WrapInFunction(
Loop(Block(If(false, Block(Break())), decl_z, cont, assign_z)));
ASSERT_TRUE(r()->Resolve()) << r()->error();
EXPECT_EQ(r()->error(), "12:34 warning: code is unreachable");
@ -105,6 +107,7 @@ TEST_F(ResolverControlBlockValidationTest, UnreachableCode_Loop_continue) {
TEST_F(ResolverControlBlockValidationTest,
UnreachableCode_Loop_continue_InBlocks) {
// loop {
// if (false) { break; }
// var z: i32;
// {{{continue;}}}
// z = 1;
@ -112,7 +115,8 @@ TEST_F(ResolverControlBlockValidationTest,
auto* decl_z = Decl(Var("z", ty.i32()));
auto* cont = Continue();
auto* assign_z = Assign(Source{{12, 34}}, "z", 1);
WrapInFunction(Loop(Block(decl_z, Block(Block(Block(cont))), assign_z)));
WrapInFunction(Loop(Block(If(false, Block(Break())), decl_z,
Block(Block(Block(cont))), assign_z)));
ASSERT_TRUE(r()->Resolve()) << r()->error();
EXPECT_EQ(r()->error(), "12:34 warning: code is unreachable");
@ -122,7 +126,7 @@ TEST_F(ResolverControlBlockValidationTest,
}
TEST_F(ResolverControlBlockValidationTest, UnreachableCode_ForLoop_continue) {
// for (;;) {
// for (;false;) {
// var z: i32;
// continue;
// z = 1;
@ -130,7 +134,7 @@ TEST_F(ResolverControlBlockValidationTest, UnreachableCode_ForLoop_continue) {
auto* decl_z = Decl(Var("z", ty.i32()));
auto* cont = Continue();
auto* assign_z = Assign(Source{{12, 34}}, "z", 1);
WrapInFunction(For(nullptr, nullptr, nullptr, //
WrapInFunction(For(nullptr, false, nullptr, //
Block(decl_z, cont, assign_z)));
ASSERT_TRUE(r()->Resolve()) << r()->error();
@ -142,7 +146,7 @@ TEST_F(ResolverControlBlockValidationTest, UnreachableCode_ForLoop_continue) {
TEST_F(ResolverControlBlockValidationTest,
UnreachableCode_ForLoop_continue_InBlocks) {
// for (;;) {
// for (;false;) {
// var z: i32;
// {{{continue;}}}
// z = 1;
@ -150,7 +154,7 @@ TEST_F(ResolverControlBlockValidationTest,
auto* decl_z = Decl(Var("z", ty.i32()));
auto* cont = Continue();
auto* assign_z = Assign(Source{{12, 34}}, "z", 1);
WrapInFunction(For(nullptr, nullptr, nullptr,
WrapInFunction(For(nullptr, false, nullptr,
Block(decl_z, Block(Block(Block(cont))), assign_z)));
ASSERT_TRUE(r()->Resolve()) << r()->error();
@ -171,10 +175,10 @@ TEST_F(ResolverControlBlockValidationTest, UnreachableCode_break) {
auto* decl_z = Decl(Var("z", ty.i32()));
auto* brk = Break();
auto* assign_z = Assign(Source{{12, 34}}, "z", 1);
WrapInFunction( //
Loop(Block(Switch(1, //
Case(Expr(1), Block(decl_z, brk, assign_z)), //
DefaultCase()))));
WrapInFunction( //
Block(Switch(1, //
Case(Expr(1), Block(decl_z, brk, assign_z)), //
DefaultCase())));
ASSERT_TRUE(r()->Resolve()) << r()->error();
EXPECT_EQ(r()->error(), "12:34 warning: code is unreachable");
@ -189,6 +193,7 @@ TEST_F(ResolverControlBlockValidationTest, UnreachableCode_break_InBlocks) {
// case 1: { {{{break;}}} var a : u32 = 2;}
// default: {}
// }
// break;
// }
auto* decl_z = Decl(Var("z", ty.i32()));
auto* brk = Break();
@ -196,7 +201,8 @@ TEST_F(ResolverControlBlockValidationTest, UnreachableCode_break_InBlocks) {
WrapInFunction(Loop(Block(
Switch(1, //
Case(Expr(1), Block(decl_z, Block(Block(Block(brk))), assign_z)),
DefaultCase()))));
DefaultCase()), //
Break())));
ASSERT_TRUE(r()->Resolve()) << r()->error();
EXPECT_EQ(r()->error(), "12:34 warning: code is unreachable");

View File

@ -1039,7 +1039,7 @@ sem::LoopStatement* Resolver::LoopStatement(const ast::LoopStatement* stmt) {
}
behaviors.Remove(sem::Behavior::kBreak, sem::Behavior::kContinue);
return true;
return ValidateLoopStatement(sem);
});
});
}

View File

@ -264,6 +264,7 @@ class Resolver {
std::unordered_set<uint32_t>& locations,
const Source& source,
const bool is_input = false);
bool ValidateLoopStatement(const sem::LoopStatement* stmt);
bool ValidateMatrix(const sem::Matrix* ty, const Source& source);
bool ValidateFunctionParameter(const ast::Function* func,
const sem::Variable* var);

View File

@ -216,7 +216,8 @@ TEST_F(ResolverBehaviorTest, StmtBreak) {
TEST_F(ResolverBehaviorTest, StmtContinue) {
auto* stmt = Continue();
WrapInFunction(Loop(Block(stmt)));
WrapInFunction(Loop(Block(If(true, Block(Break())), //
stmt)));
ASSERT_TRUE(r()->Resolve()) << r()->error();
@ -234,14 +235,12 @@ TEST_F(ResolverBehaviorTest, StmtDiscard) {
EXPECT_EQ(sem->Behaviors(), sem::Behavior::kDiscard);
}
TEST_F(ResolverBehaviorTest, StmtForLoopEmpty) {
auto* stmt = For(nullptr, nullptr, nullptr, Block());
TEST_F(ResolverBehaviorTest, StmtForLoopEmpty_NoExit) {
auto* stmt = For(Source{{12, 34}}, nullptr, nullptr, nullptr, Block());
WrapInFunction(stmt);
ASSERT_TRUE(r()->Resolve()) << r()->error();
auto* sem = Sem().Get(stmt);
EXPECT_TRUE(sem->Behaviors().Empty());
EXPECT_FALSE(r()->Resolve());
EXPECT_EQ(r()->error(), "12:34 error: for-loop does not exit");
}
TEST_F(ResolverBehaviorTest, StmtForLoopBreak) {
@ -254,14 +253,13 @@ TEST_F(ResolverBehaviorTest, StmtForLoopBreak) {
EXPECT_EQ(sem->Behaviors(), sem::Behavior::kNext);
}
TEST_F(ResolverBehaviorTest, StmtForLoopContinue) {
auto* stmt = For(nullptr, nullptr, nullptr, Block(Continue()));
TEST_F(ResolverBehaviorTest, StmtForLoopContinue_NoExit) {
auto* stmt =
For(Source{{12, 34}}, nullptr, nullptr, nullptr, Block(Continue()));
WrapInFunction(stmt);
ASSERT_TRUE(r()->Resolve()) << r()->error();
auto* sem = Sem().Get(stmt);
EXPECT_TRUE(sem->Behaviors().Empty());
EXPECT_FALSE(r()->Resolve());
EXPECT_EQ(r()->error(), "12:34 error: for-loop does not exit");
}
TEST_F(ResolverBehaviorTest, StmtForLoopDiscard) {
@ -414,14 +412,12 @@ TEST_F(ResolverBehaviorTest, StmtLetDecl_RHSDiscardOrNext) {
sem::Behaviors(sem::Behavior::kDiscard, sem::Behavior::kNext));
}
TEST_F(ResolverBehaviorTest, StmtLoopEmpty) {
auto* stmt = Loop(Block());
TEST_F(ResolverBehaviorTest, StmtLoopEmpty_NoExit) {
auto* stmt = Loop(Source{{12, 34}}, Block());
WrapInFunction(stmt);
ASSERT_TRUE(r()->Resolve()) << r()->error();
auto* sem = Sem().Get(stmt);
EXPECT_TRUE(sem->Behaviors().Empty());
EXPECT_FALSE(r()->Resolve());
EXPECT_EQ(r()->error(), "12:34 error: loop does not exit");
}
TEST_F(ResolverBehaviorTest, StmtLoopBreak) {
@ -434,14 +430,12 @@ TEST_F(ResolverBehaviorTest, StmtLoopBreak) {
EXPECT_EQ(sem->Behaviors(), sem::Behavior::kNext);
}
TEST_F(ResolverBehaviorTest, StmtLoopContinue) {
auto* stmt = Loop(Block(Continue()));
TEST_F(ResolverBehaviorTest, StmtLoopContinue_NoExit) {
auto* stmt = Loop(Source{{12, 34}}, Block(Continue()));
WrapInFunction(stmt);
ASSERT_TRUE(r()->Resolve()) << r()->error();
auto* sem = Sem().Get(stmt);
EXPECT_TRUE(sem->Behaviors().Empty());
EXPECT_FALSE(r()->Resolve());
EXPECT_EQ(r()->error(), "12:34 error: loop does not exit");
}
TEST_F(ResolverBehaviorTest, StmtLoopDiscard) {
@ -464,14 +458,12 @@ TEST_F(ResolverBehaviorTest, StmtLoopReturn) {
EXPECT_EQ(sem->Behaviors(), sem::Behavior::kReturn);
}
TEST_F(ResolverBehaviorTest, StmtLoopEmpty_ContEmpty) {
auto* stmt = Loop(Block(), Block());
TEST_F(ResolverBehaviorTest, StmtLoopEmpty_ContEmpty_NoExit) {
auto* stmt = Loop(Source{{12, 34}}, Block(), Block());
WrapInFunction(stmt);
ASSERT_TRUE(r()->Resolve()) << r()->error();
auto* sem = Sem().Get(stmt);
EXPECT_TRUE(sem->Behaviors().Empty());
EXPECT_FALSE(r()->Resolve());
EXPECT_EQ(r()->error(), "12:34 error: loop does not exit");
}
TEST_F(ResolverBehaviorTest, StmtLoopEmpty_ContBreak) {

View File

@ -200,7 +200,7 @@ TEST_F(ResolverTest, Stmt_Loop) {
auto* body_lhs = Expr("v");
auto* body_rhs = Expr(2.3f);
auto* body = Block(Assign(body_lhs, body_rhs));
auto* body = Block(Assign(body_lhs, body_rhs), Break());
auto* continuing_lhs = Expr("v");
auto* continuing_rhs = Expr(2.3f);

View File

@ -1426,7 +1426,19 @@ bool Resolver::ValidateElseStatement(const sem::ElseStatement* stmt) {
return true;
}
bool Resolver::ValidateLoopStatement(const sem::LoopStatement* stmt) {
if (stmt->Behaviors().Empty()) {
AddError("loop does not exit", stmt->Declaration()->source.Begin());
return false;
}
return true;
}
bool Resolver::ValidateForLoopStatement(const sem::ForLoopStatement* stmt) {
if (stmt->Behaviors().Empty()) {
AddError("for-loop does not exit", stmt->Declaration()->source.Begin());
return false;
}
if (auto* cond = stmt->Condition()) {
auto* cond_ty = cond->Type()->UnwrapRef();
if (!cond_ty->Is<sem::Bool>()) {

View File

@ -481,6 +481,7 @@ note: identifier 'z' referenced in continuing block here)");
TEST_F(ResolverValidationTest,
Stmt_Loop_ContinueInLoopBodyAfterDecl_UsageInContinuing_InBlocks) {
// loop {
// if (false) { break; }
// var z : i32;
// {{{continue;}}}
// continue; // Ok
@ -490,7 +491,8 @@ TEST_F(ResolverValidationTest,
// }
// }
auto* body = Block(Decl(Var("z", ty.i32(), ast::StorageClass::kNone)),
auto* body = Block(If(false, Block(Break())), //
Decl(Var("z", ty.i32(), ast::StorageClass::kNone)),
Block(Block(Block(Continue()))));
auto* continuing = Block(Assign(Expr("z"), 2));
auto* loop_stmt = Loop(body, continuing);
@ -636,7 +638,7 @@ TEST_F(ResolverValidationTest,
// break;
// }
// var z : i32;
//
// break;
// continuing {
// z = 2;
// }
@ -645,8 +647,9 @@ TEST_F(ResolverValidationTest,
auto* inner_loop = Loop(Block( //
If(true, Block(Continue())), //
Break()));
auto* body =
Block(inner_loop, Decl(Var("z", ty.i32(), ast::StorageClass::kNone)));
auto* body = Block(inner_loop, //
Decl(Var("z", ty.i32(), ast::StorageClass::kNone)), //
Break());
auto* continuing = Block(Assign("z", 2));
auto* loop_stmt = Loop(body, continuing);
WrapInFunction(loop_stmt);
@ -662,7 +665,7 @@ TEST_F(ResolverValidationTest,
// break;
// }
// var z : i32;
//
// break;
// continuing {
// if (true) {
// z = 2;
@ -672,8 +675,9 @@ TEST_F(ResolverValidationTest,
auto* inner_loop = Loop(Block(If(true, Block(Continue())), //
Break()));
auto* body =
Block(inner_loop, Decl(Var("z", ty.i32(), ast::StorageClass::kNone)));
auto* body = Block(inner_loop, //
Decl(Var("z", ty.i32(), ast::StorageClass::kNone)), //
Break());
auto* continuing = Block(If(Expr(true), Block(Assign("z", 2))));
auto* loop_stmt = Loop(body, continuing);
WrapInFunction(loop_stmt);
@ -689,19 +693,22 @@ TEST_F(ResolverValidationTest,
// break;
// }
// var z : i32;
//
// break;
// continuing {
// loop {
// z = 2;
// break;
// }
// }
// }
auto* inner_loop = Loop(Block(If(true, Block(Continue())), //
Break()));
auto* body =
Block(inner_loop, Decl(Var("z", ty.i32(), ast::StorageClass::kNone)));
auto* continuing = Block(Loop(Block(Assign("z", 2))));
auto* body = Block(inner_loop, //
Decl(Var("z", ty.i32(), ast::StorageClass::kNone)), //
Break());
auto* continuing = Block(Loop(Block(Assign("z", 2), //
Break())));
auto* loop_stmt = Loop(body, continuing);
WrapInFunction(loop_stmt);
@ -712,7 +719,7 @@ TEST_F(ResolverTest, Stmt_Loop_ContinueInLoopBodyAfterDecl_UsageInContinuing) {
// loop {
// var z : i32;
// if (true) { continue; }
//
// break;
// continuing {
// z = 2;
// }
@ -720,7 +727,8 @@ TEST_F(ResolverTest, Stmt_Loop_ContinueInLoopBodyAfterDecl_UsageInContinuing) {
auto error_loc = Source{{12, 34}};
auto* body = Block(Decl(Var("z", ty.i32(), ast::StorageClass::kNone)),
If(true, Block(Continue())));
If(true, Block(Continue())), //
Break());
auto* continuing = Block(Assign(Expr(error_loc, "z"), 2));
auto* loop_stmt = Loop(body, continuing);
WrapInFunction(loop_stmt);
@ -748,6 +756,7 @@ TEST_F(ResolverTest, Stmt_Loop_ReturnInContinuing_Direct) {
TEST_F(ResolverTest, Stmt_Loop_ReturnInContinuing_Indirect) {
// loop {
// if (false) { break; }
// continuing {
// loop {
// return;
@ -755,11 +764,11 @@ TEST_F(ResolverTest, Stmt_Loop_ReturnInContinuing_Indirect) {
// }
// }
WrapInFunction(Loop( // outer loop
Block(), // outer loop block
Block(Source{{56, 78}}, // outer loop continuing block
Loop( // inner loop
Block( // inner loop block
WrapInFunction(Loop( // outer loop
Block(If(false, Block(Break()))), // outer loop block
Block(Source{{56, 78}}, // outer loop continuing block
Loop( // inner loop
Block( // inner loop block
Return(Source{{12, 34}}))))));
EXPECT_FALSE(r()->Resolve());
@ -789,16 +798,17 @@ TEST_F(ResolverTest, Stmt_Loop_DiscardInContinuing_Direct) {
TEST_F(ResolverTest, Stmt_Loop_DiscardInContinuing_Indirect) {
// loop {
// if (false) { break; }
// continuing {
// loop { discard; }
// }
// }
WrapInFunction(Loop( // outer loop
Block(), // outer loop block
Block(Source{{56, 78}}, // outer loop continuing block
Loop( // inner loop
Block( // inner loop block
WrapInFunction(Loop( // outer loop
Block(If(false, Block(Break()))), // outer loop block
Block(Source{{56, 78}}, // outer loop continuing block
Loop( // inner loop
Block( // inner loop block
Discard(Source{{12, 34}}))))));
EXPECT_FALSE(r()->Resolve());
@ -854,19 +864,23 @@ TEST_F(ResolverTest, Stmt_Loop_ContinueInContinuing_Direct) {
TEST_F(ResolverTest, Stmt_Loop_ContinueInContinuing_Indirect) {
// loop {
// if (false) { break; }
// continuing {
// loop {
// if (false) { break; }
// continue;
// }
// }
// }
WrapInFunction(Loop( // outer loop
Block(), // outer loop block
Block( // outer loop continuing block
Loop( // inner loop
Block( // inner loop block
Continue(Source{{12, 34}}))))));
WrapInFunction(Loop( // outer loop
Block( // outer loop block
If(false, Block(Break()))), // if (false) { break; }
Block( // outer loop continuing block
Loop( // inner loop
Block( // inner loop block
If(false, Block(Break())), // if (false) { break; }
Continue(Source{{12, 34}})))))); // continue
EXPECT_TRUE(r()->Resolve()) << r()->error();
}
@ -970,13 +984,14 @@ TEST_F(ResolverTest, Stmt_ForLoop_ContinueInContinuing_Direct) {
}
TEST_F(ResolverTest, Stmt_ForLoop_ContinueInContinuing_Indirect) {
// for(;; loop { continue }) {
// for(;; loop { if (false) { break; } continue }) {
// break;
// }
WrapInFunction(For(nullptr, nullptr,
Loop( //
Block(Continue(Source{{12, 34}}))), //
Block(If(false, Block(Break())), //
Continue(Source{{12, 34}}))), //
Block(Break())));
EXPECT_TRUE(r()->Resolve()) << r()->error();
@ -1004,7 +1019,8 @@ TEST_F(ResolverTest, Stmt_ForLoop_CondIsNotBool) {
}
TEST_F(ResolverValidationTest, Stmt_ContinueInLoop) {
WrapInFunction(Loop(Block(Continue(Source{{12, 34}}))));
WrapInFunction(Loop(Block(If(false, Block(Break())), //
Continue(Source{{12, 34}}))));
EXPECT_TRUE(r()->Resolve()) << r()->error();
}
@ -1015,20 +1031,21 @@ TEST_F(ResolverValidationTest, Stmt_ContinueNotInLoop) {
}
TEST_F(ResolverValidationTest, Stmt_BreakInLoop) {
WrapInFunction(Loop(Block(create<ast::BreakStatement>(Source{{12, 34}}))));
WrapInFunction(Loop(Block(Break(Source{{12, 34}}))));
EXPECT_TRUE(r()->Resolve()) << r()->error();
}
TEST_F(ResolverValidationTest, Stmt_BreakInSwitch) {
WrapInFunction(Loop(Block(Switch(
Expr(1),
Case(Expr(1), Block(create<ast::BreakStatement>(Source{{12, 34}}))),
DefaultCase()))));
WrapInFunction(Loop(Block(Switch(Expr(1), //
Case(Expr(1), //
Block(Break())), //
DefaultCase()), //
Break()))); //
EXPECT_TRUE(r()->Resolve()) << r()->error();
}
TEST_F(ResolverValidationTest, Stmt_BreakNotInLoopOrSwitch) {
WrapInFunction(create<ast::BreakStatement>(Source{{12, 34}}));
WrapInFunction(Break(Source{{12, 34}}));
EXPECT_FALSE(r()->Resolve());
EXPECT_EQ(r()->error(),
"12:34 error: break statement must be in a loop or switch case");

View File

@ -36,6 +36,7 @@ TEST_F(ForLoopToLoopTest, Empty) {
auto* src = R"(
fn f() {
for (;;) {
break;
}
}
)";
@ -43,6 +44,7 @@ fn f() {
auto* expect = R"(
fn f() {
loop {
break;
}
}
)";
@ -80,7 +82,7 @@ TEST_F(ForLoopToLoopTest, InitializerStatementDecl) {
auto* src = R"(
fn f() {
for (var i: i32;;) {
break;
}
}
)";
@ -90,6 +92,7 @@ fn f() {
{
var i : i32;
loop {
break;
}
}
}
@ -106,6 +109,7 @@ TEST_F(ForLoopToLoopTest, InitializerStatementDeclEqual) {
auto* src = R"(
fn f() {
for (var i: i32 = 0;;) {
break;
}
}
)";
@ -115,6 +119,7 @@ fn f() {
{
var i : i32 = 0;
loop {
break;
}
}
}
@ -130,6 +135,7 @@ TEST_F(ForLoopToLoopTest, InitializerStatementConstDecl) {
auto* src = R"(
fn f() {
for (let i: i32 = 0;;) {
break;
}
}
)";
@ -139,6 +145,7 @@ fn f() {
{
let i : i32 = 0;
loop {
break;
}
}
}
@ -155,7 +162,7 @@ TEST_F(ForLoopToLoopTest, InitializerStatementAssignment) {
fn f() {
var i: i32;
for (i = 0;;) {
break;
}
}
)";
@ -166,6 +173,7 @@ fn f() {
{
i = 0;
loop {
break;
}
}
}
@ -185,7 +193,9 @@ fn a(x : i32, y : i32) {
fn f() {
var b : i32;
var c : i32;
for (a(b,c);;) { }
for (a(b,c);;) {
break;
}
}
)";
@ -199,6 +209,7 @@ fn f() {
{
a(b, c);
loop {
break;
}
}
}
@ -239,6 +250,7 @@ TEST_F(ForLoopToLoopTest, ContinuingAssignment) {
fn f() {
var x: i32;
for (;;x = 2) {
break;
}
}
)";
@ -247,6 +259,7 @@ fn f() {
fn f() {
var x : i32;
loop {
break;
continuing {
x = 2;
@ -270,6 +283,7 @@ fn f() {
var b : i32;
var c : i32;
for (;;a(b,c)) {
break;
}
}
)";
@ -282,6 +296,7 @@ fn f() {
var b : i32;
var c : i32;
loop {
break;
continuing {
a(b, c);

View File

@ -85,6 +85,7 @@ TEST_F(PromoteInitializersToConstVarTest, ArrayInForLoopInit) {
fn f() {
var insert_after = 1;
for(var i = array<f32, 4u>(0.0, 1.0, 2.0, 3.0)[2]; ; ) {
break;
}
}
)";
@ -94,6 +95,7 @@ fn f() {
var insert_after = 1;
let tint_symbol = array<f32, 4u>(0.0, 1.0, 2.0, 3.0);
for(var i = tint_symbol[2]; ; ) {
break;
}
}
)";
@ -114,6 +116,7 @@ struct S {
fn f() {
var insert_after = 1;
for(var x = S(1, 2.0, vec3<f32>()).b; ; ) {
break;
}
}
)";
@ -129,6 +132,7 @@ fn f() {
var insert_after = 1;
let tint_symbol = S(1, 2.0, vec3<f32>());
for(var x = tint_symbol.b; ; ) {
break;
}
}
)";

View File

@ -331,11 +331,13 @@ fn f() {
EXPECT_EQ(expect, str(got));
}
TEST_F(RemoveUnreachableStatementsTest, LoopWithNoBreak) {
TEST_F(RemoveUnreachableStatementsTest, LoopWithDiscard) {
auto* src = R"(
fn f() {
loop {
var a = 1;
discard;
continuing {
var b = 2;
}
@ -351,6 +353,7 @@ fn f() {
fn f() {
loop {
var a = 1;
discard;
continuing {
var b = 2;

View File

@ -254,6 +254,7 @@ fn main() {
var arr = array<f32, 4>();
for (let a = &arr[foo()]; ;) {
let x = *a;
break;
}
}
)";
@ -269,6 +270,7 @@ fn main() {
let a_save = foo();
for(; ; ) {
let x = arr[a_save];
break;
}
}
)";

View File

@ -22,7 +22,8 @@ namespace {
using GlslGeneratorImplTest_Continue = TestHelper;
TEST_F(GlslGeneratorImplTest_Continue, Emit_Continue) {
auto* loop = Loop(Block(create<ast::ContinueStatement>()));
auto* loop = Loop(Block(If(false, Block(Break())), //
Continue()));
WrapInFunction(loop);
GeneratorImpl& gen = Build();
@ -31,6 +32,9 @@ TEST_F(GlslGeneratorImplTest_Continue, Emit_Continue) {
ASSERT_TRUE(gen.EmitStatement(loop)) << gen.error();
EXPECT_EQ(gen.result(), R"( while (true) {
if (false) {
break;
}
continue;
}
)");

View File

@ -106,34 +106,18 @@ TEST_F(GlslGeneratorImplTest_Loop, Emit_LoopWithVarUsedInContinuing) {
// loop {
// var lhs : f32 = 2.4;
// var other : f32;
// break;
// continuing {
// lhs = rhs
// }
// }
//
// ->
// {
// float lhs;
// float other;
// for (;;) {
// if (continuing) {
// lhs = rhs;
// }
// lhs = 2.4f;
// other = 0.0f;
// }
// }
Global("rhs", ty.f32(), ast::StorageClass::kPrivate);
auto* var = Var("lhs", ty.f32(), ast::StorageClass::kNone, Expr(2.4f));
auto* body = Block(Decl(var), Decl(Var("other", ty.f32())));
auto* lhs = Expr("lhs");
auto* rhs = Expr("rhs");
auto* continuing = Block(Assign(lhs, rhs));
auto* body = Block(Decl(Var("lhs", ty.f32(), Expr(2.4f))), //
Decl(Var("other", ty.f32())), //
Break());
auto* continuing = Block(Assign("lhs", "rhs"));
auto* outer = Loop(body, continuing);
WrapInFunction(outer);
@ -145,6 +129,7 @@ TEST_F(GlslGeneratorImplTest_Loop, Emit_LoopWithVarUsedInContinuing) {
EXPECT_EQ(gen.result(), R"( while (true) {
float lhs = 2.400000095f;
float other = 0.0f;
break;
{
lhs = rhs;
}
@ -157,10 +142,8 @@ TEST_F(GlslGeneratorImplTest_Loop, Emit_ForLoop) {
// return;
// }
Func("a_statement", {}, ty.void_(), {});
auto* f =
For(nullptr, nullptr, nullptr, Block(CallStmt(Call("a_statement"))));
auto* f = For(nullptr, nullptr, nullptr, //
Block(Return()));
WrapInFunction(f);
GeneratorImpl& gen = Build();
@ -170,7 +153,7 @@ TEST_F(GlslGeneratorImplTest_Loop, Emit_ForLoop) {
ASSERT_TRUE(gen.EmitStatement(f)) << gen.error();
EXPECT_EQ(gen.result(), R"( {
for(; ; ) {
a_statement();
return;
}
}
)");
@ -181,10 +164,8 @@ TEST_F(GlslGeneratorImplTest_Loop, Emit_ForLoopWithSimpleInit) {
// return;
// }
Func("a_statement", {}, ty.void_(), {});
auto* f = For(Decl(Var("i", ty.i32())), nullptr, nullptr,
Block(CallStmt(Call("a_statement"))));
auto* f = For(Decl(Var("i", ty.i32())), nullptr, nullptr, //
Block(Return()));
WrapInFunction(f);
GeneratorImpl& gen = Build();
@ -194,7 +175,7 @@ TEST_F(GlslGeneratorImplTest_Loop, Emit_ForLoopWithSimpleInit) {
ASSERT_TRUE(gen.EmitStatement(f)) << gen.error();
EXPECT_EQ(gen.result(), R"( {
for(int i = 0; ; ) {
a_statement();
return;
}
}
)");
@ -204,12 +185,11 @@ TEST_F(GlslGeneratorImplTest_Loop, Emit_ForLoopWithMultiStmtInit) {
// for(var b = true && false; ; ) {
// return;
// }
Func("a_statement", {}, ty.void_(), {});
auto* multi_stmt = create<ast::BinaryExpression>(ast::BinaryOp::kLogicalAnd,
Expr(true), Expr(false));
auto* f = For(Decl(Var("b", nullptr, multi_stmt)), nullptr, nullptr,
Block(CallStmt(Call("a_statement"))));
Block(Return()));
WrapInFunction(f);
GeneratorImpl& gen = Build();
@ -224,7 +204,7 @@ TEST_F(GlslGeneratorImplTest_Loop, Emit_ForLoopWithMultiStmtInit) {
}
bool b = (tint_tmp);
for(; ; ) {
a_statement();
return;
}
}
)");
@ -289,11 +269,9 @@ TEST_F(GlslGeneratorImplTest_Loop, Emit_ForLoopWithSimpleCont) {
// return;
// }
Func("a_statement", {}, ty.void_(), {});
auto* v = Decl(Var("i", ty.i32()));
auto* f = For(nullptr, nullptr, Assign("i", Add("i", 1)),
Block(CallStmt(Call("a_statement"))));
auto* f = For(nullptr, nullptr, Assign("i", Add("i", 1)), //
Block(Return()));
WrapInFunction(v, f);
GeneratorImpl& gen = Build();
@ -303,7 +281,7 @@ TEST_F(GlslGeneratorImplTest_Loop, Emit_ForLoopWithSimpleCont) {
ASSERT_TRUE(gen.EmitStatement(f)) << gen.error();
EXPECT_EQ(gen.result(), R"( {
for(; ; i = (i + 1)) {
a_statement();
return;
}
}
)");
@ -314,13 +292,11 @@ TEST_F(GlslGeneratorImplTest_Loop, Emit_ForLoopWithMultiStmtCont) {
// return;
// }
Func("a_statement", {}, ty.void_(), {});
auto* multi_stmt = create<ast::BinaryExpression>(ast::BinaryOp::kLogicalAnd,
Expr(true), Expr(false));
auto* v = Decl(Var("i", ty.bool_()));
auto* f = For(nullptr, nullptr, Assign("i", multi_stmt),
Block(CallStmt(Call("a_statement"))));
auto* f = For(nullptr, nullptr, Assign("i", multi_stmt), //
Block(Return()));
WrapInFunction(v, f);
GeneratorImpl& gen = Build();
@ -330,7 +306,7 @@ TEST_F(GlslGeneratorImplTest_Loop, Emit_ForLoopWithMultiStmtCont) {
ASSERT_TRUE(gen.EmitStatement(f)) << gen.error();
EXPECT_EQ(gen.result(), R"( {
while (true) {
a_statement();
return;
bool tint_tmp = true;
if (tint_tmp) {
tint_tmp = false;
@ -346,10 +322,8 @@ TEST_F(GlslGeneratorImplTest_Loop, Emit_ForLoopWithSimpleInitCondCont) {
// return;
// }
Func("a_statement", {}, ty.void_(), {});
auto* f = For(Decl(Var("i", ty.i32())), true, Assign("i", Add("i", 1)),
Block(CallStmt(Call("a_statement"))));
Block(Return()));
WrapInFunction(f);
GeneratorImpl& gen = Build();
@ -359,7 +333,7 @@ TEST_F(GlslGeneratorImplTest_Loop, Emit_ForLoopWithSimpleInitCondCont) {
ASSERT_TRUE(gen.EmitStatement(f)) << gen.error();
EXPECT_EQ(gen.result(), R"( {
for(int i = 0; true; i = (i + 1)) {
a_statement();
return;
}
}
)");
@ -369,7 +343,6 @@ TEST_F(GlslGeneratorImplTest_Loop, Emit_ForLoopWithMultiStmtInitCondCont) {
// for(var i = true && false; true && false; i = true && false) {
// return;
// }
Func("a_statement", {}, ty.void_(), {});
auto* multi_stmt_a = create<ast::BinaryExpression>(ast::BinaryOp::kLogicalAnd,
Expr(true), Expr(false));
@ -378,9 +351,9 @@ TEST_F(GlslGeneratorImplTest_Loop, Emit_ForLoopWithMultiStmtInitCondCont) {
auto* multi_stmt_c = create<ast::BinaryExpression>(ast::BinaryOp::kLogicalAnd,
Expr(true), Expr(false));
auto* f =
For(Decl(Var("i", nullptr, multi_stmt_a)), multi_stmt_b,
Assign("i", multi_stmt_c), Block(CallStmt(Call("a_statement"))));
auto* f = For(Decl(Var("i", nullptr, multi_stmt_a)), multi_stmt_b,
Assign("i", multi_stmt_c), //
Block(Return()));
WrapInFunction(f);
GeneratorImpl& gen = Build();
@ -400,7 +373,7 @@ TEST_F(GlslGeneratorImplTest_Loop, Emit_ForLoopWithMultiStmtInitCondCont) {
tint_tmp_1 = false;
}
if (!((tint_tmp_1))) { break; }
a_statement();
return;
bool tint_tmp_2 = true;
if (tint_tmp_2) {
tint_tmp_2 = false;

View File

@ -22,7 +22,8 @@ namespace {
using HlslGeneratorImplTest_Continue = TestHelper;
TEST_F(HlslGeneratorImplTest_Continue, Emit_Continue) {
auto* loop = Loop(Block(create<ast::ContinueStatement>()));
auto* loop = Loop(Block(If(false, Block(Break())), //
Continue()));
WrapInFunction(loop);
GeneratorImpl& gen = Build();
@ -31,6 +32,9 @@ TEST_F(HlslGeneratorImplTest_Continue, Emit_Continue) {
ASSERT_TRUE(gen.EmitStatement(loop)) << gen.error();
EXPECT_EQ(gen.result(), R"( [loop] while (true) {
if (false) {
break;
}
continue;
}
)");

View File

@ -106,34 +106,19 @@ TEST_F(HlslGeneratorImplTest_Loop, Emit_LoopWithVarUsedInContinuing) {
// loop {
// var lhs : f32 = 2.4;
// var other : f32;
// break;
// continuing {
// lhs = rhs
// }
// }
//
// ->
// {
// float lhs;
// float other;
// for (;;) {
// if (continuing) {
// lhs = rhs;
// }
// lhs = 2.4f;
// other = 0.0f;
// }
// }
Global("rhs", ty.f32(), ast::StorageClass::kPrivate);
auto* var = Var("lhs", ty.f32(), ast::StorageClass::kNone, Expr(2.4f));
auto* body = Block(Decl(Var("lhs", ty.f32(), Expr(2.4f))), //
Decl(Var("other", ty.f32())), //
Break());
auto* body = Block(Decl(var), Decl(Var("other", ty.f32())));
auto* lhs = Expr("lhs");
auto* rhs = Expr("rhs");
auto* continuing = Block(Assign(lhs, rhs));
auto* continuing = Block(Assign("lhs", "rhs"));
auto* outer = Loop(body, continuing);
WrapInFunction(outer);
@ -145,6 +130,7 @@ TEST_F(HlslGeneratorImplTest_Loop, Emit_LoopWithVarUsedInContinuing) {
EXPECT_EQ(gen.result(), R"( [loop] while (true) {
float lhs = 2.400000095f;
float other = 0.0f;
break;
{
lhs = rhs;
}
@ -157,10 +143,7 @@ TEST_F(HlslGeneratorImplTest_Loop, Emit_ForLoop) {
// return;
// }
Func("a_statement", {}, ty.void_(), {});
auto* f =
For(nullptr, nullptr, nullptr, Block(CallStmt(Call("a_statement"))));
auto* f = For(nullptr, nullptr, nullptr, Block(Return()));
WrapInFunction(f);
GeneratorImpl& gen = Build();
@ -170,7 +153,7 @@ TEST_F(HlslGeneratorImplTest_Loop, Emit_ForLoop) {
ASSERT_TRUE(gen.EmitStatement(f)) << gen.error();
EXPECT_EQ(gen.result(), R"( {
[loop] for(; ; ) {
a_statement();
return;
}
}
)");
@ -181,10 +164,7 @@ TEST_F(HlslGeneratorImplTest_Loop, Emit_ForLoopWithSimpleInit) {
// return;
// }
Func("a_statement", {}, ty.void_(), {});
auto* f = For(Decl(Var("i", ty.i32())), nullptr, nullptr,
Block(CallStmt(Call("a_statement"))));
auto* f = For(Decl(Var("i", ty.i32())), nullptr, nullptr, Block(Return()));
WrapInFunction(f);
GeneratorImpl& gen = Build();
@ -194,7 +174,7 @@ TEST_F(HlslGeneratorImplTest_Loop, Emit_ForLoopWithSimpleInit) {
ASSERT_TRUE(gen.EmitStatement(f)) << gen.error();
EXPECT_EQ(gen.result(), R"( {
[loop] for(int i = 0; ; ) {
a_statement();
return;
}
}
)");
@ -204,12 +184,11 @@ TEST_F(HlslGeneratorImplTest_Loop, Emit_ForLoopWithMultiStmtInit) {
// for(var b = true && false; ; ) {
// return;
// }
Func("a_statement", {}, ty.void_(), {});
auto* multi_stmt = create<ast::BinaryExpression>(ast::BinaryOp::kLogicalAnd,
Expr(true), Expr(false));
auto* f = For(Decl(Var("b", nullptr, multi_stmt)), nullptr, nullptr,
Block(CallStmt(Call("a_statement"))));
Block(Return()));
WrapInFunction(f);
GeneratorImpl& gen = Build();
@ -224,7 +203,7 @@ TEST_F(HlslGeneratorImplTest_Loop, Emit_ForLoopWithMultiStmtInit) {
}
bool b = (tint_tmp);
[loop] for(; ; ) {
a_statement();
return;
}
}
)");
@ -235,9 +214,7 @@ TEST_F(HlslGeneratorImplTest_Loop, Emit_ForLoopWithSimpleCond) {
// return;
// }
Func("a_statement", {}, ty.void_(), {});
auto* f = For(nullptr, true, nullptr, Block(CallStmt(Call("a_statement"))));
auto* f = For(nullptr, true, nullptr, Block(Return()));
WrapInFunction(f);
GeneratorImpl& gen = Build();
@ -247,7 +224,7 @@ TEST_F(HlslGeneratorImplTest_Loop, Emit_ForLoopWithSimpleCond) {
ASSERT_TRUE(gen.EmitStatement(f)) << gen.error();
EXPECT_EQ(gen.result(), R"( {
[loop] for(; true; ) {
a_statement();
return;
}
}
)");
@ -258,12 +235,9 @@ TEST_F(HlslGeneratorImplTest_Loop, Emit_ForLoopWithMultiStmtCond) {
// return;
// }
Func("a_statement", {}, ty.void_(), {});
auto* multi_stmt = create<ast::BinaryExpression>(ast::BinaryOp::kLogicalAnd,
Expr(true), Expr(false));
auto* f =
For(nullptr, multi_stmt, nullptr, Block(CallStmt(Call("a_statement"))));
auto* f = For(nullptr, multi_stmt, nullptr, Block(Return()));
WrapInFunction(f);
GeneratorImpl& gen = Build();
@ -278,7 +252,7 @@ TEST_F(HlslGeneratorImplTest_Loop, Emit_ForLoopWithMultiStmtCond) {
tint_tmp = false;
}
if (!((tint_tmp))) { break; }
a_statement();
return;
}
}
)");
@ -289,11 +263,8 @@ TEST_F(HlslGeneratorImplTest_Loop, Emit_ForLoopWithSimpleCont) {
// return;
// }
Func("a_statement", {}, ty.void_(), {});
auto* v = Decl(Var("i", ty.i32()));
auto* f = For(nullptr, nullptr, Assign("i", Add("i", 1)),
Block(CallStmt(Call("a_statement"))));
auto* f = For(nullptr, nullptr, Assign("i", Add("i", 1)), Block(Return()));
WrapInFunction(v, f);
GeneratorImpl& gen = Build();
@ -303,7 +274,7 @@ TEST_F(HlslGeneratorImplTest_Loop, Emit_ForLoopWithSimpleCont) {
ASSERT_TRUE(gen.EmitStatement(f)) << gen.error();
EXPECT_EQ(gen.result(), R"( {
[loop] for(; ; i = (i + 1)) {
a_statement();
return;
}
}
)");
@ -314,13 +285,10 @@ TEST_F(HlslGeneratorImplTest_Loop, Emit_ForLoopWithMultiStmtCont) {
// return;
// }
Func("a_statement", {}, ty.void_(), {});
auto* multi_stmt = create<ast::BinaryExpression>(ast::BinaryOp::kLogicalAnd,
Expr(true), Expr(false));
auto* v = Decl(Var("i", ty.bool_()));
auto* f = For(nullptr, nullptr, Assign("i", multi_stmt),
Block(CallStmt(Call("a_statement"))));
auto* f = For(nullptr, nullptr, Assign("i", multi_stmt), Block(Return()));
WrapInFunction(v, f);
GeneratorImpl& gen = Build();
@ -330,7 +298,7 @@ TEST_F(HlslGeneratorImplTest_Loop, Emit_ForLoopWithMultiStmtCont) {
ASSERT_TRUE(gen.EmitStatement(f)) << gen.error();
EXPECT_EQ(gen.result(), R"( {
[loop] while (true) {
a_statement();
return;
bool tint_tmp = true;
if (tint_tmp) {
tint_tmp = false;
@ -346,10 +314,8 @@ TEST_F(HlslGeneratorImplTest_Loop, Emit_ForLoopWithSimpleInitCondCont) {
// return;
// }
Func("a_statement", {}, ty.void_(), {});
auto* f = For(Decl(Var("i", ty.i32())), true, Assign("i", Add("i", 1)),
Block(CallStmt(Call("a_statement"))));
Block(Return()));
WrapInFunction(f);
GeneratorImpl& gen = Build();
@ -359,7 +325,7 @@ TEST_F(HlslGeneratorImplTest_Loop, Emit_ForLoopWithSimpleInitCondCont) {
ASSERT_TRUE(gen.EmitStatement(f)) << gen.error();
EXPECT_EQ(gen.result(), R"( {
[loop] for(int i = 0; true; i = (i + 1)) {
a_statement();
return;
}
}
)");
@ -369,7 +335,6 @@ TEST_F(HlslGeneratorImplTest_Loop, Emit_ForLoopWithMultiStmtInitCondCont) {
// for(var i = true && false; true && false; i = true && false) {
// return;
// }
Func("a_statement", {}, ty.void_(), {});
auto* multi_stmt_a = create<ast::BinaryExpression>(ast::BinaryOp::kLogicalAnd,
Expr(true), Expr(false));
@ -378,9 +343,8 @@ TEST_F(HlslGeneratorImplTest_Loop, Emit_ForLoopWithMultiStmtInitCondCont) {
auto* multi_stmt_c = create<ast::BinaryExpression>(ast::BinaryOp::kLogicalAnd,
Expr(true), Expr(false));
auto* f =
For(Decl(Var("i", nullptr, multi_stmt_a)), multi_stmt_b,
Assign("i", multi_stmt_c), Block(CallStmt(Call("a_statement"))));
auto* f = For(Decl(Var("i", nullptr, multi_stmt_a)), multi_stmt_b,
Assign("i", multi_stmt_c), Block(Return()));
WrapInFunction(f);
GeneratorImpl& gen = Build();
@ -400,7 +364,7 @@ TEST_F(HlslGeneratorImplTest_Loop, Emit_ForLoopWithMultiStmtInitCondCont) {
tint_tmp_1 = false;
}
if (!((tint_tmp_1))) { break; }
a_statement();
return;
bool tint_tmp_2 = true;
if (tint_tmp_2) {
tint_tmp_2 = false;

View File

@ -22,7 +22,8 @@ namespace {
using MslGeneratorImplTest = TestHelper;
TEST_F(MslGeneratorImplTest, Emit_Continue) {
auto* loop = Loop(Block(create<ast::ContinueStatement>()));
auto* loop = Loop(Block(If(false, Block(Break())), //
Continue()));
WrapInFunction(loop);
GeneratorImpl& gen = Build();
@ -31,6 +32,9 @@ TEST_F(MslGeneratorImplTest, Emit_Continue) {
ASSERT_TRUE(gen.EmitStatement(loop)) << gen.error();
EXPECT_EQ(gen.result(), R"( while (true) {
if (false) {
break;
}
continue;
}
)");

View File

@ -106,27 +106,14 @@ TEST_F(MslGeneratorImplTest, Emit_LoopWithVarUsedInContinuing) {
// }
// }
//
// ->
// {
// float lhs;
// float other;
// for (;;) {
// if (continuing) {
// lhs = rhs;
// }
// lhs = 2.4f;
// other = 0.0f;
// }
// }
Global("rhs", ty.f32(), ast::StorageClass::kPrivate);
auto* var = Var("lhs", ty.f32(), ast::StorageClass::kNone, Expr(2.4f));
auto* body = Block(Decl(var), Decl(Var("other", ty.f32())));
auto* body = Block(Decl(Var("lhs", ty.f32(), Expr(2.4f))), //
Decl(Var("other", ty.f32())), //
Break());
auto* continuing = Block(Assign("lhs", "rhs"));
auto* outer = Loop(body, continuing);
WrapInFunction(outer);
@ -138,6 +125,7 @@ TEST_F(MslGeneratorImplTest, Emit_LoopWithVarUsedInContinuing) {
EXPECT_EQ(gen.result(), R"( while (true) {
float lhs = 2.400000095f;
float other = 0.0f;
break;
{
lhs = rhs;
}
@ -150,10 +138,8 @@ TEST_F(MslGeneratorImplTest, Emit_ForLoop) {
// return;
// }
Func("a_statement", {}, ty.void_(), {});
auto* f =
For(nullptr, nullptr, nullptr, Block(CallStmt(Call("a_statement"))));
auto* f = For(nullptr, nullptr, nullptr, //
Block(Return()));
WrapInFunction(f);
GeneratorImpl& gen = Build();
@ -162,7 +148,7 @@ TEST_F(MslGeneratorImplTest, Emit_ForLoop) {
ASSERT_TRUE(gen.EmitStatement(f)) << gen.error();
EXPECT_EQ(gen.result(), R"( for(; ; ) {
a_statement();
return;
}
)");
}
@ -172,10 +158,8 @@ TEST_F(MslGeneratorImplTest, Emit_ForLoopWithSimpleInit) {
// return;
// }
Func("a_statement", {}, ty.void_(), {});
auto* f = For(Decl(Var("i", ty.i32())), nullptr, nullptr,
Block(CallStmt(Call("a_statement"))));
auto* f = For(Decl(Var("i", ty.i32())), nullptr, nullptr, //
Block(Return()));
WrapInFunction(f);
GeneratorImpl& gen = Build();
@ -184,7 +168,7 @@ TEST_F(MslGeneratorImplTest, Emit_ForLoopWithSimpleInit) {
ASSERT_TRUE(gen.EmitStatement(f)) << gen.error();
EXPECT_EQ(gen.result(), R"( for(int i = 0; ; ) {
a_statement();
return;
}
)");
}
@ -200,12 +184,10 @@ TEST_F(MslGeneratorImplTest, Emit_ForLoopWithMultiStmtInit) {
Func("f", {Param("i", ty.i32())}, ty.void_(), {});
auto f = [&](auto&& expr) { return CallStmt(Call("f", expr)); };
Func("a_statement", {}, ty.void_(), {});
Global("a", ty.atomic<i32>(), ast::StorageClass::kWorkgroup);
auto* multi_stmt = Block(f(1), f(2));
auto* loop =
For(multi_stmt, nullptr, nullptr, Block(CallStmt(Call("a_statement"))));
auto* loop = For(multi_stmt, nullptr, nullptr, //
Block(Return()));
WrapInFunction(loop);
GeneratorImpl& gen = Build();
@ -219,7 +201,7 @@ TEST_F(MslGeneratorImplTest, Emit_ForLoopWithMultiStmtInit) {
f(2);
}
for(; ; ) {
a_statement();
return;
}
}
)");
@ -230,9 +212,8 @@ TEST_F(MslGeneratorImplTest, Emit_ForLoopWithSimpleCond) {
// return;
// }
Func("a_statement", {}, ty.void_(), {});
auto* f = For(nullptr, true, nullptr, Block(CallStmt(Call("a_statement"))));
auto* f = For(nullptr, true, nullptr, //
Block(Return()));
WrapInFunction(f);
GeneratorImpl& gen = Build();
@ -241,7 +222,7 @@ TEST_F(MslGeneratorImplTest, Emit_ForLoopWithSimpleCond) {
ASSERT_TRUE(gen.EmitStatement(f)) << gen.error();
EXPECT_EQ(gen.result(), R"( for(; true; ) {
a_statement();
return;
}
)");
}
@ -251,11 +232,9 @@ TEST_F(MslGeneratorImplTest, Emit_ForLoopWithSimpleCont) {
// return;
// }
Func("a_statement", {}, ty.void_(), {});
auto* v = Decl(Var("i", ty.i32()));
auto* f = For(nullptr, nullptr, Assign("i", Add("i", 1)),
Block(CallStmt(Call("a_statement"))));
auto* f = For(nullptr, nullptr, Assign("i", Add("i", 1)), //
Block(Return()));
WrapInFunction(v, f);
GeneratorImpl& gen = Build();
@ -266,7 +245,7 @@ TEST_F(MslGeneratorImplTest, Emit_ForLoopWithSimpleCont) {
EXPECT_EQ(
gen.result(),
R"( for(; ; i = as_type<int>((as_type<uint>(i) + as_type<uint>(1)))) {
a_statement();
return;
}
)");
}
@ -282,12 +261,10 @@ TEST_F(MslGeneratorImplTest, Emit_ForLoopWithMultiStmtCont) {
Func("f", {Param("i", ty.i32())}, ty.void_(), {});
auto f = [&](auto&& expr) { return CallStmt(Call("f", expr)); };
Func("a_statement", {}, ty.void_(), {});
Global("a", ty.atomic<i32>(), ast::StorageClass::kWorkgroup);
auto* multi_stmt = Block(f(1), f(2));
auto* loop =
For(nullptr, nullptr, multi_stmt, Block(CallStmt(Call("a_statement"))));
auto* loop = For(nullptr, nullptr, multi_stmt, //
Block(Return()));
WrapInFunction(loop);
GeneratorImpl& gen = Build();
@ -296,7 +273,7 @@ TEST_F(MslGeneratorImplTest, Emit_ForLoopWithMultiStmtCont) {
ASSERT_TRUE(gen.EmitStatement(loop)) << gen.error();
EXPECT_EQ(gen.result(), R"( while (true) {
a_statement();
return;
{
f(1);
f(2);
@ -340,13 +317,11 @@ TEST_F(MslGeneratorImplTest, Emit_ForLoopWithMultiStmtInitCondCont) {
Func("f", {Param("i", ty.i32())}, ty.void_(), {});
auto f = [&](auto&& expr) { return CallStmt(Call("f", expr)); };
Func("a_statement", {}, ty.void_(), {});
Global("a", ty.atomic<i32>(), ast::StorageClass::kWorkgroup);
auto* multi_stmt_a = Block(f(1), f(2));
auto* multi_stmt_b = Block(f(3), f(4));
auto* loop = For(multi_stmt_a, Expr(true), multi_stmt_b,
Block(CallStmt(Call("a_statement"))));
auto* loop = For(multi_stmt_a, Expr(true), multi_stmt_b, //
Block(Return()));
WrapInFunction(loop);
GeneratorImpl& gen = Build();
@ -361,7 +336,7 @@ TEST_F(MslGeneratorImplTest, Emit_ForLoopWithMultiStmtInitCondCont) {
}
while (true) {
if (!(true)) { break; }
a_statement();
return;
{
f(3);
f(4);

View File

@ -25,10 +25,7 @@ using BuilderTest = TestHelper;
TEST_F(BuilderTest, If_Empty) {
// if (true) {
// }
auto* cond = Expr(true);
auto* expr =
create<ast::IfStatement>(cond, Block(), ast::ElseStatementList{});
auto* expr = If(true, Block());
WrapInFunction(expr);
spirv::Builder& b = Build();
@ -52,11 +49,9 @@ TEST_F(BuilderTest, If_Empty_OutsideFunction_IsError) {
// Outside a function.
// if (true) {
// }
auto* cond = Expr(true);
ast::ElseStatementList elses;
auto* block = Block();
auto* expr = create<ast::IfStatement>(cond, block, elses);
auto* expr = If(true, block);
WrapInFunction(expr);
spirv::Builder& b = Build();
@ -75,8 +70,7 @@ TEST_F(BuilderTest, If_WithStatements) {
auto* var = Global("v", ty.i32(), ast::StorageClass::kPrivate);
auto* body = Block(Assign("v", 2));
auto* expr =
create<ast::IfStatement>(Expr(true), body, ast::ElseStatementList{});
auto* expr = If(true, body);
WrapInFunction(expr);
spirv::Builder& b = Build();
@ -114,9 +108,7 @@ TEST_F(BuilderTest, If_WithElse) {
auto* body = Block(Assign("v", 2));
auto* else_body = Block(Assign("v", 3));
auto* expr = create<ast::IfStatement>(
Expr(true), body,
ast::ElseStatementList{create<ast::ElseStatement>(nullptr, else_body)});
auto* expr = If(true, body, Else(else_body));
WrapInFunction(expr);
spirv::Builder& b = Build();
@ -158,11 +150,7 @@ TEST_F(BuilderTest, If_WithElseIf) {
auto* body = Block(Assign("v", 2));
auto* else_body = Block(Assign("v", 3));
auto* expr = create<ast::IfStatement>(
Expr(true), body,
ast::ElseStatementList{
create<ast::ElseStatement>(Expr(true), else_body),
});
auto* expr = If(true, body, Else(true, else_body));
WrapInFunction(expr);
spirv::Builder& b = Build();
@ -215,13 +203,10 @@ TEST_F(BuilderTest, If_WithMultiple) {
auto* elseif_2_body = Block(Assign("v", 4));
auto* else_body = Block(Assign("v", 5));
auto* expr = create<ast::IfStatement>(
Expr(true), body,
ast::ElseStatementList{
create<ast::ElseStatement>(Expr(true), elseif_1_body),
create<ast::ElseStatement>(Expr(false), elseif_2_body),
create<ast::ElseStatement>(nullptr, else_body),
});
auto* expr = If(true, body, //
Else(true, elseif_1_body), //
Else(false, elseif_2_body), //
Else(else_body));
WrapInFunction(expr);
spirv::Builder& b = Build();
@ -278,10 +263,9 @@ TEST_F(BuilderTest, If_WithBreak) {
// }
// }
auto* if_body = Block(create<ast::BreakStatement>());
auto* if_body = Block(Break());
auto* if_stmt =
create<ast::IfStatement>(Expr(true), if_body, ast::ElseStatementList{});
auto* if_stmt = If(true, if_body);
auto* loop_body = Block(if_stmt);
@ -321,11 +305,9 @@ TEST_F(BuilderTest, If_WithElseBreak) {
// break;
// }
// }
auto* else_body = Block(create<ast::BreakStatement>());
auto* else_body = Block(Break());
auto* if_stmt = create<ast::IfStatement>(
Expr(true), Block(),
ast::ElseStatementList{create<ast::ElseStatement>(nullptr, else_body)});
auto* if_stmt = If(true, Block(), Else(else_body));
auto* loop_body = Block(if_stmt);
@ -360,20 +342,18 @@ OpBranch %1
)");
}
TEST_F(BuilderTest, If_WithContinue) {
TEST_F(BuilderTest, If_WithContinueAndBreak) {
// loop {
// if (true) {
// continue;
// } else {
// break;
// }
// }
auto* if_body = Block(create<ast::ContinueStatement>());
auto* if_stmt =
create<ast::IfStatement>(Expr(true), if_body, ast::ElseStatementList{});
auto* if_stmt = If(true, Block(Continue()), Else(Block(Break())));
auto* loop_body = Block(if_stmt);
auto* expr = Loop(loop_body, Block());
auto* expr = Loop(Block(if_stmt), Block());
WrapInFunction(expr);
spirv::Builder& b = Build();
@ -391,9 +371,11 @@ OpLoopMerge %2 %3 None
OpBranch %4
%4 = OpLabel
OpSelectionMerge %7 None
OpBranchConditional %6 %8 %7
OpBranchConditional %6 %8 %9
%8 = OpLabel
OpBranch %3
%9 = OpLabel
OpBranch %2
%7 = OpLabel
OpBranch %3
%3 = OpLabel
@ -408,14 +390,13 @@ TEST_F(BuilderTest, If_WithElseContinue) {
// } else {
// continue;
// }
// break;
// }
auto* else_body = Block(create<ast::ContinueStatement>());
auto* if_stmt = create<ast::IfStatement>(
Expr(true), Block(),
ast::ElseStatementList{create<ast::ElseStatement>(nullptr, else_body)});
auto* if_stmt = If(true, Block(), Else(else_body));
auto* loop_body = Block(if_stmt);
auto* loop_body = Block(if_stmt, Break());
auto* expr = Loop(loop_body, Block());
WrapInFunction(expr);
@ -441,7 +422,7 @@ OpBranch %7
%9 = OpLabel
OpBranch %3
%7 = OpLabel
OpBranch %3
OpBranch %2
%3 = OpLabel
OpBranch %1
%2 = OpLabel
@ -610,8 +591,7 @@ TEST_F(BuilderTest, If_ElseIf_WithReturn) {
// return;
// }
auto* if_stmt = If(Expr(false), Block(),
ast::ElseStatementList{Else(Expr(true), Block(Return()))});
auto* if_stmt = If(false, Block(), Else(true, Block(Return())));
auto* fn = Func("f", {}, ty.void_(), {if_stmt});
spirv::Builder& b = Build();
@ -649,8 +629,7 @@ TEST_F(BuilderTest, Loop_If_ElseIf_WithBreak) {
// }
// }
auto* if_stmt = If(Expr(false), Block(),
ast::ElseStatementList{Else(Expr(true), Block(Break()))});
auto* if_stmt = If(false, Block(), Else(true, Block(Break())));
auto* fn = Func("f", {}, ty.void_(), {Loop(Block(if_stmt))});
spirv::Builder& b = Build();

View File

@ -24,9 +24,10 @@ using BuilderTest = TestHelper;
TEST_F(BuilderTest, Loop_Empty) {
// loop {
// break;
// }
auto* loop = Loop(Block(), Block());
auto* loop = Loop(Block(Break()), Block());
WrapInFunction(loop);
spirv::Builder& b = Build();
@ -40,7 +41,7 @@ TEST_F(BuilderTest, Loop_Empty) {
OpLoopMerge %2 %3 None
OpBranch %4
%4 = OpLabel
OpBranch %3
OpBranch %2
%3 = OpLabel
OpBranch %1
%2 = OpLabel
@ -50,10 +51,12 @@ OpBranch %1
TEST_F(BuilderTest, Loop_WithoutContinuing) {
// loop {
// v = 2;
// break;
// }
auto* var = Global("v", ty.i32(), ast::StorageClass::kPrivate);
auto* body = Block(Assign("v", 2));
auto* body = Block(Assign("v", 2), //
Break());
auto* loop = Loop(body, Block());
WrapInFunction(loop);
@ -77,7 +80,7 @@ OpLoopMerge %6 %7 None
OpBranch %8
%8 = OpLabel
OpStore %1 %9
OpBranch %7
OpBranch %6
%7 = OpLabel
OpBranch %5
%6 = OpLabel
@ -87,13 +90,15 @@ OpBranch %5
TEST_F(BuilderTest, Loop_WithContinuing) {
// loop {
// a = 2;
// break;
// continuing {
// a = 3;
// }
// }
auto* var = Global("v", ty.i32(), ast::StorageClass::kPrivate);
auto* body = Block(Assign("v", 2));
auto* body = Block(Assign("v", 2), //
Break());
auto* continuing = Block(Assign("v", 3));
auto* loop = Loop(body, continuing);
@ -119,7 +124,7 @@ OpLoopMerge %6 %7 None
OpBranch %8
%8 = OpLabel
OpStore %1 %9
OpBranch %7
OpBranch %6
%7 = OpLabel
OpStore %1 %10
OpBranch %5
@ -130,14 +135,14 @@ OpBranch %5
TEST_F(BuilderTest, Loop_WithBodyVariableAccessInContinuing) {
// loop {
// var a : i32;
// break;
// continuing {
// a = 3;
// }
// }
auto* var = Var("a", ty.i32());
auto* var_decl = WrapInStatement(var);
auto* body = Block(var_decl);
auto* body = Block(Decl(Var("a", ty.i32())), //
Break());
auto* continuing = Block(Assign("a", 3));
auto* loop = Loop(body, continuing);
@ -159,7 +164,7 @@ TEST_F(BuilderTest, Loop_WithBodyVariableAccessInContinuing) {
OpLoopMerge %2 %3 None
OpBranch %4
%4 = OpLabel
OpBranch %3
OpBranch %2
%3 = OpLabel
OpStore %5 %9
OpBranch %1
@ -169,9 +174,11 @@ OpBranch %1
TEST_F(BuilderTest, Loop_WithContinue) {
// loop {
// if (false) { break; }
// continue;
// }
auto* body = Block(create<ast::ContinueStatement>());
auto* body = Block(If(false, Block(Break())), //
Continue());
auto* loop = Loop(body, Block());
WrapInFunction(loop);
@ -186,6 +193,11 @@ TEST_F(BuilderTest, Loop_WithContinue) {
OpLoopMerge %2 %3 None
OpBranch %4
%4 = OpLabel
OpSelectionMerge %7 None
OpBranchConditional %6 %8 %7
%8 = OpLabel
OpBranch %2
%7 = OpLabel
OpBranch %3
%3 = OpLabel
OpBranch %1

View File

@ -22,8 +22,10 @@ namespace {
using WgslGeneratorImplTest = TestHelper;
TEST_F(WgslGeneratorImplTest, Emit_Continue) {
auto* c = create<ast::ContinueStatement>();
WrapInFunction(Loop(Block(c)));
auto* c = Continue();
WrapInFunction(Loop(Block(If(false, Block(Break())), //
c)));
GeneratorImpl& gen = Build();

View File

@ -1,4 +1,4 @@
fn f() {
var i : i32;
for (let p = &i;;) {}
for (let p = &i; false;) {}
}

View File

@ -6,7 +6,7 @@ void unused_entry_point() {
void f() {
int i = 0;
{
[loop] for(; ; ) {
[loop] for(; false; ) {
}
}
}

View File

@ -3,7 +3,7 @@
using namespace metal;
void f() {
int i = 0;
for(; ; ) {
for(; false; ) {
}
}

View File

@ -1,7 +1,7 @@
; SPIR-V
; Version: 1.3
; Generator: Google Tint Compiler; 0
; Bound: 15
; Bound: 20
; Schema: 0
OpCapability Shader
OpMemoryModel Logical GLSL450
@ -15,6 +15,8 @@
%int = OpTypeInt 32 1
%_ptr_Function_int = OpTypePointer Function %int
%10 = OpConstantNull %int
%bool = OpTypeBool
%false = OpConstantFalse %bool
%unused_entry_point = OpFunction %void None %1
%4 = OpLabel
OpReturn
@ -27,6 +29,12 @@
OpLoopMerge %12 %13 None
OpBranch %14
%14 = OpLabel
%15 = OpLogicalNot %bool %false
OpSelectionMerge %18 None
OpBranchConditional %15 %19 %18
%19 = OpLabel
OpBranch %12
%18 = OpLabel
OpBranch %13
%13 = OpLabel
OpBranch %11

View File

@ -1,5 +1,5 @@
fn f() {
var i : i32;
for(let p = &(i); ; ) {
for(let p = &(i); false; ) {
}
}

View File

@ -18,4 +18,3 @@ void f() {
return;
}
C:\src\tint\test\Shader@0x000001A817AB3700(7,11-19): error X3708: continue cannot be used in a switch

View File

@ -1,4 +1,4 @@
fn f() {
var i : i32;
for (;;i = i + array<i32, 1>(1)[0]) {}
for (; false; i = i + array<i32, 1>(1)[0]) {}
}

View File

@ -6,6 +6,9 @@ void unused_entry_point() {
void f() {
int i = 0;
[loop] while (true) {
if (!(false)) {
break;
}
{
const int tint_symbol[1] = {1};
i = (i + tint_symbol[0]);

View File

@ -8,6 +8,9 @@ struct tint_array_wrapper {
void f() {
int i = 0;
while (true) {
if (!(false)) {
break;
}
{
tint_array_wrapper const tint_symbol = {.arr={1}};
i = as_type<int>((as_type<uint>(i) + as_type<uint>(tint_symbol.arr[0])));

View File

@ -1,7 +1,7 @@
; SPIR-V
; Version: 1.3
; Generator: Google Tint Compiler; 0
; Bound: 24
; Bound: 29
; Schema: 0
OpCapability Shader
OpMemoryModel Logical GLSL450
@ -16,11 +16,13 @@
%int = OpTypeInt 32 1
%_ptr_Function_int = OpTypePointer Function %int
%10 = OpConstantNull %int
%bool = OpTypeBool
%false = OpConstantFalse %bool
%uint = OpTypeInt 32 0
%uint_1 = OpConstant %uint 1
%_arr_int_uint_1 = OpTypeArray %int %uint_1
%int_1 = OpConstant %int 1
%20 = OpConstantComposite %_arr_int_uint_1 %int_1
%25 = OpConstantComposite %_arr_int_uint_1 %int_1
%int_0 = OpConstant %int 0
%unused_entry_point = OpFunction %void None %1
%4 = OpLabel
@ -34,12 +36,18 @@
OpLoopMerge %12 %13 None
OpBranch %14
%14 = OpLabel
%15 = OpLogicalNot %bool %false
OpSelectionMerge %18 None
OpBranchConditional %15 %19 %18
%19 = OpLabel
OpBranch %12
%18 = OpLabel
OpBranch %13
%13 = OpLabel
%15 = OpLoad %int %i
%22 = OpCompositeExtract %int %20 0
%23 = OpIAdd %int %15 %22
OpStore %i %23
%20 = OpLoad %int %i
%27 = OpCompositeExtract %int %25 0
%28 = OpIAdd %int %20 %27
OpStore %i %28
OpBranch %11
%12 = OpLabel
OpReturn

View File

@ -1,5 +1,5 @@
fn f() {
var i : i32;
for(; ; i = (i + array<i32, 1>(1)[0])) {
for(; false; i = (i + array<i32, 1>(1)[0])) {
}
}

View File

@ -1,4 +1,4 @@
fn f() {
var i : i32;
for (;;i = i + 1) {}
for (; false; i = i + 1) {}
}

View File

@ -6,7 +6,7 @@ void unused_entry_point() {
void f() {
int i = 0;
{
[loop] for(; ; i = (i + 1)) {
[loop] for(; false; i = (i + 1)) {
}
}
}

View File

@ -3,7 +3,7 @@
using namespace metal;
void f() {
int i = 0;
for(; ; i = as_type<int>((as_type<uint>(i) + as_type<uint>(1)))) {
for(; false; i = as_type<int>((as_type<uint>(i) + as_type<uint>(1)))) {
}
}

View File

@ -1,7 +1,7 @@
; SPIR-V
; Version: 1.3
; Generator: Google Tint Compiler; 0
; Bound: 18
; Bound: 23
; Schema: 0
OpCapability Shader
OpMemoryModel Logical GLSL450
@ -15,6 +15,8 @@
%int = OpTypeInt 32 1
%_ptr_Function_int = OpTypePointer Function %int
%10 = OpConstantNull %int
%bool = OpTypeBool
%false = OpConstantFalse %bool
%int_1 = OpConstant %int 1
%unused_entry_point = OpFunction %void None %1
%4 = OpLabel
@ -28,11 +30,17 @@
OpLoopMerge %12 %13 None
OpBranch %14
%14 = OpLabel
%15 = OpLogicalNot %bool %false
OpSelectionMerge %18 None
OpBranchConditional %15 %19 %18
%19 = OpLabel
OpBranch %12
%18 = OpLabel
OpBranch %13
%13 = OpLabel
%15 = OpLoad %int %i
%17 = OpIAdd %int %15 %int_1
OpStore %i %17
%20 = OpLoad %int %i
%22 = OpIAdd %int %20 %int_1
OpStore %i %22
OpBranch %11
%12 = OpLabel
OpReturn

View File

@ -1,5 +1,5 @@
fn f() {
var i : i32;
for(; ; i = (i + 1)) {
for(; false; i = (i + 1)) {
}
}

View File

@ -3,5 +3,5 @@ struct S {
};
fn f() {
for (var i = 0;; i = i + S(1).i) {}
for (var i = 0; false; i = i + S(1).i) {}
}

View File

@ -11,6 +11,9 @@ void f() {
{
int i = 0;
[loop] while (true) {
if (!(false)) {
break;
}
{
const S tint_symbol = {1};
i = (i + tint_symbol.i);

View File

@ -9,6 +9,9 @@ void f() {
{
int i = 0;
while (true) {
if (!(false)) {
break;
}
{
S const tint_symbol = {.i=1};
i = as_type<int>((as_type<uint>(i) + as_type<uint>(tint_symbol.i)));

View File

@ -1,7 +1,7 @@
; SPIR-V
; Version: 1.3
; Generator: Google Tint Compiler; 0
; Bound: 22
; Bound: 27
; Schema: 0
OpCapability Shader
OpMemoryModel Logical GLSL450
@ -19,9 +19,11 @@
%int_0 = OpConstant %int 0
%_ptr_Function_int = OpTypePointer Function %int
%11 = OpConstantNull %int
%bool = OpTypeBool
%false = OpConstantFalse %bool
%S = OpTypeStruct %int
%int_1 = OpConstant %int 1
%19 = OpConstantComposite %S %int_1
%24 = OpConstantComposite %S %int_1
%unused_entry_point = OpFunction %void None %1
%4 = OpLabel
OpReturn
@ -35,12 +37,18 @@
OpLoopMerge %13 %14 None
OpBranch %15
%15 = OpLabel
%16 = OpLogicalNot %bool %false
OpSelectionMerge %19 None
OpBranchConditional %16 %20 %19
%20 = OpLabel
OpBranch %13
%19 = OpLabel
OpBranch %14
%14 = OpLabel
%16 = OpLoad %int %i
%20 = OpCompositeExtract %int %19 0
%21 = OpIAdd %int %16 %20
OpStore %i %21
%21 = OpLoad %int %i
%25 = OpCompositeExtract %int %24 0
%26 = OpIAdd %int %21 %25
OpStore %i %26
OpBranch %12
%13 = OpLabel
OpReturn

View File

@ -3,6 +3,6 @@ struct S {
};
fn f() {
for(var i = 0; ; i = (i + S(1).i)) {
for(var i = 0; false; i = (i + S(1).i)) {
}
}

View File

@ -1,3 +1,3 @@
fn f() {
for (;;) {}
for (; false;) {}
}

View File

@ -5,7 +5,7 @@ void unused_entry_point() {
void f() {
{
[loop] for(; ; ) {
[loop] for(; false; ) {
}
}
}

View File

@ -2,7 +2,7 @@
using namespace metal;
void f() {
for(; ; ) {
for(; false; ) {
}
}

View File

@ -1,7 +1,7 @@
; SPIR-V
; Version: 1.3
; Generator: Google Tint Compiler; 0
; Bound: 11
; Bound: 16
; Schema: 0
OpCapability Shader
OpMemoryModel Logical GLSL450
@ -11,6 +11,8 @@
OpName %f "f"
%void = OpTypeVoid
%1 = OpTypeFunction %void
%bool = OpTypeBool
%false = OpConstantFalse %bool
%unused_entry_point = OpFunction %void None %1
%4 = OpLabel
OpReturn
@ -22,6 +24,12 @@
OpLoopMerge %8 %9 None
OpBranch %10
%10 = OpLabel
%11 = OpLogicalNot %bool %false
OpSelectionMerge %14 None
OpBranchConditional %11 %15 %14
%15 = OpLabel
OpBranch %8
%14 = OpLabel
OpBranch %9
%9 = OpLabel
OpBranch %7

View File

@ -1,4 +1,4 @@
fn f() {
for(; ; ) {
for(; false; ) {
}
}

View File

@ -1,3 +1,3 @@
fn f() {
for (var i : i32 = array<i32, 1>(1)[0];;) {}
for (var i : i32 = array<i32, 1>(1)[0]; false;) {}
}

View File

@ -6,7 +6,7 @@ void unused_entry_point() {
void f() {
const int tint_symbol[1] = {1};
{
[loop] for(int i = tint_symbol[0]; ; ) {
[loop] for(int i = tint_symbol[0]; false; ) {
}
}
}

View File

@ -7,7 +7,7 @@ struct tint_array_wrapper {
void f() {
tint_array_wrapper const tint_symbol = {.arr={1}};
for(int i = tint_symbol.arr[0]; ; ) {
for(int i = tint_symbol.arr[0]; false; ) {
}
}

View File

@ -1,7 +1,7 @@
; SPIR-V
; Version: 1.3
; Generator: Google Tint Compiler; 0
; Bound: 22
; Bound: 27
; Schema: 0
OpCapability Shader
OpMemoryModel Logical GLSL450
@ -22,6 +22,8 @@
%int_0 = OpConstant %int 0
%_ptr_Function_int = OpTypePointer Function %int
%17 = OpConstantNull %int
%bool = OpTypeBool
%false = OpConstantFalse %bool
%unused_entry_point = OpFunction %void None %1
%4 = OpLabel
OpReturn
@ -36,6 +38,12 @@
OpLoopMerge %19 %20 None
OpBranch %21
%21 = OpLabel
%22 = OpLogicalNot %bool %false
OpSelectionMerge %25 None
OpBranchConditional %22 %26 %25
%26 = OpLabel
OpBranch %19
%25 = OpLabel
OpBranch %20
%20 = OpLabel
OpBranch %18

View File

@ -1,4 +1,4 @@
fn f() {
for(var i : i32 = array<i32, 1>(1)[0]; ; ) {
for(var i : i32 = array<i32, 1>(1)[0]; false; ) {
}
}

View File

@ -1,3 +1,3 @@
fn f() {
for (var i : i32 = 0;;) {}
for (var i : i32 = 0; false;) {}
}

View File

@ -5,7 +5,7 @@ void unused_entry_point() {
void f() {
{
[loop] for(int i = 0; ; ) {
[loop] for(int i = 0; false; ) {
}
}
}

View File

@ -2,7 +2,7 @@
using namespace metal;
void f() {
for(int i = 0; ; ) {
for(int i = 0; false; ) {
}
}

View File

@ -1,7 +1,7 @@
; SPIR-V
; Version: 1.3
; Generator: Google Tint Compiler; 0
; Bound: 16
; Bound: 21
; Schema: 0
OpCapability Shader
OpMemoryModel Logical GLSL450
@ -16,6 +16,8 @@
%int_0 = OpConstant %int 0
%_ptr_Function_int = OpTypePointer Function %int
%11 = OpConstantNull %int
%bool = OpTypeBool
%false = OpConstantFalse %bool
%unused_entry_point = OpFunction %void None %1
%4 = OpLabel
OpReturn
@ -29,6 +31,12 @@
OpLoopMerge %13 %14 None
OpBranch %15
%15 = OpLabel
%16 = OpLogicalNot %bool %false
OpSelectionMerge %19 None
OpBranchConditional %16 %20 %19
%20 = OpLabel
OpBranch %13
%19 = OpLabel
OpBranch %14
%14 = OpLabel
OpBranch %12

View File

@ -1,4 +1,4 @@
fn f() {
for(var i : i32 = 0; ; ) {
for(var i : i32 = 0; false; ) {
}
}

View File

@ -3,5 +3,5 @@ struct S {
};
fn f() {
for (var i : i32 = S(1).i;;) {}
for (var i : i32 = S(1).i; false;) {}
}

View File

@ -10,7 +10,7 @@ struct S {
void f() {
const S tint_symbol = {1};
{
[loop] for(int i = tint_symbol.i; ; ) {
[loop] for(int i = tint_symbol.i; false; ) {
}
}
}

View File

@ -7,7 +7,7 @@ struct S {
void f() {
S const tint_symbol = {.i=1};
for(int i = tint_symbol.i; ; ) {
for(int i = tint_symbol.i; false; ) {
}
}

View File

@ -1,7 +1,7 @@
; SPIR-V
; Version: 1.3
; Generator: Google Tint Compiler; 0
; Bound: 19
; Bound: 24
; Schema: 0
OpCapability Shader
OpMemoryModel Logical GLSL450
@ -21,6 +21,8 @@
%10 = OpConstantComposite %S %int_1
%_ptr_Function_int = OpTypePointer Function %int
%14 = OpConstantNull %int
%bool = OpTypeBool
%false = OpConstantFalse %bool
%unused_entry_point = OpFunction %void None %1
%4 = OpLabel
OpReturn
@ -35,6 +37,12 @@
OpLoopMerge %16 %17 None
OpBranch %18
%18 = OpLabel
%19 = OpLogicalNot %bool %false
OpSelectionMerge %22 None
OpBranchConditional %19 %23 %22
%23 = OpLabel
OpBranch %16
%22 = OpLabel
OpBranch %17
%17 = OpLabel
OpBranch %15

View File

@ -3,6 +3,6 @@ struct S {
};
fn f() {
for(var i : i32 = S(1).i; ; ) {
for(var i : i32 = S(1).i; false; ) {
}
}

View File

@ -1,5 +1,6 @@
SKIP: FAILED
warning: use of deprecated intrinsic
void main_1() {
const bool2 x_1 = isnan(float2(50.0f, 60.0f));
return;
@ -9,6 +10,3 @@ void main() {
main_1();
return;
}
Internal Compiler error: cast<X>() argument of incompatible type!

View File

@ -3,7 +3,7 @@ SKIP: FAILED
static uint var_1 = 0u;
void main_1() {
while (true) {
[loop] while (true) {
if (false) {
} else {
break;

View File

@ -4,7 +4,7 @@ static uint var_1 = 0u;
void main_1() {
{
for(; !(false); ) {
[loop] for(; !(false); ) {
}
}
return;
@ -17,7 +17,7 @@ void main() {
warning: DXIL.dll not found. Resulting DXIL will not be signed for use in release environments.
error: validation errors
tint_Pui8tf:11: error: Loop must have break.
/tmp/tint_ePdsZG:11: error: Loop must have break.
Validation failed.

View File

@ -3,7 +3,7 @@ SKIP: FAILED
static uint var_1 = 0u;
void main_1() {
while (true) {
[loop] while (true) {
if (false) {
} else {
break;

View File

@ -3,7 +3,7 @@ SKIP: FAILED
static uint var_1 = 0u;
void main_1() {
while (true) {
[loop] while (true) {
if (false) {
break;
}
@ -18,7 +18,7 @@ void main() {
warning: DXIL.dll not found. Resulting DXIL will not be signed for use in release environments.
error: validation errors
tint_5BECUW:12: error: Loop must have break.
/tmp/tint_1aGHmE:12: error: Loop must have break.
Validation failed.

View File

@ -1,51 +0,0 @@
; Test: SpvParserCFGTest_ComputeBlockOrder_Loop_SingleBlock_DupInfinite.spvasm
; SPIR-V
; Version: 1.0
; Generator: Khronos SPIR-V Tools Assembler; 0
; Bound: 1000
; Schema: 0
OpCapability Shader
OpMemoryModel Logical Simple
OpEntryPoint Fragment %100 "main"
OpExecutionMode %100 OriginUpperLeft
OpName %var "var"
%void = OpTypeVoid
%3 = OpTypeFunction %void
%bool = OpTypeBool
%5 = OpConstantNull %bool
%true = OpConstantTrue %bool
%false = OpConstantFalse %bool
%uint = OpTypeInt 32 0
%int = OpTypeInt 32 1
%uint_42 = OpConstant %uint 42
%int_42 = OpConstant %int 42
%13 = OpTypeFunction %uint
%uint_0 = OpConstant %uint 0
%uint_1 = OpConstant %uint 1
%uint_2 = OpConstant %uint 2
%uint_3 = OpConstant %uint 3
%uint_4 = OpConstant %uint 4
%uint_5 = OpConstant %uint 5
%uint_6 = OpConstant %uint 6
%uint_7 = OpConstant %uint 7
%uint_8 = OpConstant %uint 8
%uint_10 = OpConstant %uint 10
%uint_20 = OpConstant %uint 20
%uint_30 = OpConstant %uint 30
%uint_40 = OpConstant %uint 40
%uint_50 = OpConstant %uint 50
%uint_90 = OpConstant %uint 90
%uint_99 = OpConstant %uint 99
%_ptr_Private_uint = OpTypePointer Private %uint
%var = OpVariable %_ptr_Private_uint Private
%uint_999 = OpConstant %uint 999
%100 = OpFunction %void None %3
%10 = OpLabel
OpBranch %20
%20 = OpLabel
OpLoopMerge %99 %20 None
OpBranchConditional %5 %20 %20
%99 = OpLabel
OpReturn
OpFunctionEnd

View File

@ -1,22 +0,0 @@
SKIP: FAILED
static uint var_1 = 0u;
void main_1() {
while (true) {
}
return;
}
void main() {
main_1();
return;
}
warning: DXIL.dll not found. Resulting DXIL will not be signed for use in release environments.
error: validation errors
tint_ow9VQQ:9: error: Loop must have break.
Validation failed.

View File

@ -1,51 +0,0 @@
; Test: SpvParserCFGTest_ComputeBlockOrder_Loop_SingleBlock_Infinite.spvasm
; SPIR-V
; Version: 1.0
; Generator: Khronos SPIR-V Tools Assembler; 0
; Bound: 1000
; Schema: 0
OpCapability Shader
OpMemoryModel Logical Simple
OpEntryPoint Fragment %100 "main"
OpExecutionMode %100 OriginUpperLeft
OpName %var "var"
%void = OpTypeVoid
%3 = OpTypeFunction %void
%bool = OpTypeBool
%5 = OpConstantNull %bool
%true = OpConstantTrue %bool
%false = OpConstantFalse %bool
%uint = OpTypeInt 32 0
%int = OpTypeInt 32 1
%uint_42 = OpConstant %uint 42
%int_42 = OpConstant %int 42
%13 = OpTypeFunction %uint
%uint_0 = OpConstant %uint 0
%uint_1 = OpConstant %uint 1
%uint_2 = OpConstant %uint 2
%uint_3 = OpConstant %uint 3
%uint_4 = OpConstant %uint 4
%uint_5 = OpConstant %uint 5
%uint_6 = OpConstant %uint 6
%uint_7 = OpConstant %uint 7
%uint_8 = OpConstant %uint 8
%uint_10 = OpConstant %uint 10
%uint_20 = OpConstant %uint 20
%uint_30 = OpConstant %uint 30
%uint_40 = OpConstant %uint 40
%uint_50 = OpConstant %uint 50
%uint_90 = OpConstant %uint 90
%uint_99 = OpConstant %uint 99
%_ptr_Private_uint = OpTypePointer Private %uint
%var = OpVariable %_ptr_Private_uint Private
%uint_999 = OpConstant %uint 999
%100 = OpFunction %void None %3
%10 = OpLabel
OpBranch %20
%20 = OpLabel
OpLoopMerge %99 %20 None
OpBranch %20
%99 = OpLabel
OpReturn
OpFunctionEnd

View File

@ -1,22 +0,0 @@
SKIP: FAILED
static uint var_1 = 0u;
void main_1() {
while (true) {
}
return;
}
void main() {
main_1();
return;
}
warning: DXIL.dll not found. Resulting DXIL will not be signed for use in release environments.
error: validation errors
tint_py60tZ:9: error: Loop must have break.
Validation failed.

View File

@ -4,7 +4,7 @@ static uint var_1 = 0u;
void main_1() {
var_1 = 0u;
while (true) {
[loop] while (true) {
var_1 = 1u;
{
if (false) {
@ -23,7 +23,7 @@ void main() {
warning: DXIL.dll not found. Resulting DXIL will not be signed for use in release environments.
error: validation errors
tint_7IQZev:17: error: Loop must have break.
/tmp/tint_M0JS53:17: error: Loop must have break.
Validation failed.

View File

@ -1,25 +1,20 @@
SKIP: FAILED
static uint var_1 = 0u;
void main_1() {
var<private> var_1 : u32;
fn main_1() {
var_1 = 0u;
while (true) {
loop {
var_1 = 1u;
}
var_1 = 5u;
return;
}
void main() {
[[stage(fragment)]]
fn main() {
main_1();
return;
}
warning: DXIL.dll not found. Resulting DXIL will not be signed for use in release environments.
error: validation errors
tint_43uiR4:12: error: Loop must have break.
Validation failed.
error: loop does not exit

View File

@ -0,0 +1,20 @@
SKIP: FAILED
var<private> var_1 : u32;
fn main_1() {
var_1 = 0u;
loop {
var_1 = 1u;
}
var_1 = 5u;
return;
}
[[stage(fragment)]]
fn main() {
main_1();
}
error: loop does not exit

View File

@ -0,0 +1,20 @@
SKIP: FAILED
var<private> var_1 : u32;
fn main_1() {
var_1 = 0u;
loop {
var_1 = 1u;
}
var_1 = 5u;
return;
}
[[stage(fragment)]]
fn main() {
main_1();
}
error: loop does not exit

View File

@ -0,0 +1,20 @@
SKIP: FAILED
var<private> var_1 : u32;
fn main_1() {
var_1 = 0u;
loop {
var_1 = 1u;
}
var_1 = 5u;
return;
}
[[stage(fragment)]]
fn main() {
main_1();
}
error: loop does not exit

View File

@ -4,7 +4,7 @@ static uint var_1 = 0u;
void main_1() {
var_1 = 0u;
while (true) {
[loop] while (true) {
var_1 = 1u;
if (false) {
break;
@ -21,7 +21,7 @@ void main() {
warning: DXIL.dll not found. Resulting DXIL will not be signed for use in release environments.
error: validation errors
tint_ZN83ug:15: error: Loop must have break.
/tmp/tint_9dTIlS:15: error: Loop must have break.
Validation failed.

View File

@ -1,21 +1,20 @@
SKIP: FAILED
static uint var_1 = 0u;
void main_1() {
var<private> var_1 : u32;
fn main_1() {
var_1 = 0u;
while (true) {
loop {
var_1 = 1u;
var_1 = 2u;
if (true) {
var_1 = 3u;
{
var_1 = 5u;
}
continue;
}
var_1 = 4u;
{
continuing {
var_1 = 5u;
}
}
@ -23,15 +22,9 @@ void main_1() {
return;
}
void main() {
[[stage(fragment)]]
fn main() {
main_1();
return;
}
warning: DXIL.dll not found. Resulting DXIL will not be signed for use in release environments.
error: validation errors
tint_8eZRxk:24: error: Loop must have break.
Validation failed.
error: loop does not exit

View File

@ -0,0 +1,30 @@
SKIP: FAILED
var<private> var_1 : u32;
fn main_1() {
var_1 = 0u;
loop {
var_1 = 1u;
var_1 = 2u;
if (true) {
var_1 = 3u;
continue;
}
var_1 = 4u;
continuing {
var_1 = 5u;
}
}
var_1 = 6u;
return;
}
[[stage(fragment)]]
fn main() {
main_1();
}
error: loop does not exit

View File

@ -0,0 +1,30 @@
SKIP: FAILED
var<private> var_1 : u32;
fn main_1() {
var_1 = 0u;
loop {
var_1 = 1u;
var_1 = 2u;
if (true) {
var_1 = 3u;
continue;
}
var_1 = 4u;
continuing {
var_1 = 5u;
}
}
var_1 = 6u;
return;
}
[[stage(fragment)]]
fn main() {
main_1();
}
error: loop does not exit

View File

@ -0,0 +1,30 @@
SKIP: FAILED
var<private> var_1 : u32;
fn main_1() {
var_1 = 0u;
loop {
var_1 = 1u;
var_1 = 2u;
if (true) {
var_1 = 3u;
continue;
}
var_1 = 4u;
continuing {
var_1 = 5u;
}
}
var_1 = 6u;
return;
}
[[stage(fragment)]]
fn main() {
main_1();
}
error: loop does not exit

View File

@ -1,10 +1,11 @@
SKIP: FAILED
static uint var_1 = 0u;
void main_1() {
var<private> var_1 : u32;
fn main_1() {
var_1 = 0u;
while (true) {
loop {
var_1 = 1u;
var_1 = 2u;
if (true) {
@ -17,15 +18,9 @@ void main_1() {
return;
}
void main() {
[[stage(fragment)]]
fn main() {
main_1();
return;
}
warning: DXIL.dll not found. Resulting DXIL will not be signed for use in release environments.
error: validation errors
tint_qTM1ZY:18: error: Loop must have break.
Validation failed.
error: loop does not exit

View File

@ -0,0 +1,26 @@
SKIP: FAILED
var<private> var_1 : u32;
fn main_1() {
var_1 = 0u;
loop {
var_1 = 1u;
var_1 = 2u;
if (true) {
var_1 = 3u;
continue;
}
var_1 = 4u;
}
var_1 = 6u;
return;
}
[[stage(fragment)]]
fn main() {
main_1();
}
error: loop does not exit

View File

@ -0,0 +1,26 @@
SKIP: FAILED
var<private> var_1 : u32;
fn main_1() {
var_1 = 0u;
loop {
var_1 = 1u;
var_1 = 2u;
if (true) {
var_1 = 3u;
continue;
}
var_1 = 4u;
}
var_1 = 6u;
return;
}
[[stage(fragment)]]
fn main() {
main_1();
}
error: loop does not exit

View File

@ -0,0 +1,26 @@
SKIP: FAILED
var<private> var_1 : u32;
fn main_1() {
var_1 = 0u;
loop {
var_1 = 1u;
var_1 = 2u;
if (true) {
var_1 = 3u;
continue;
}
var_1 = 4u;
}
var_1 = 6u;
return;
}
[[stage(fragment)]]
fn main() {
main_1();
}
error: loop does not exit

View File

@ -1,13 +1,15 @@
SKIP: FAILED
static uint var_1 = 0u;
void main_1() {
var<private> var_1 : u32;
fn main_1() {
var_1 = 0u;
while (true) {
loop {
var_1 = 1u;
var_1 = 2u;
{
continuing {
var_1 = 4u;
}
}
@ -15,15 +17,9 @@ void main_1() {
return;
}
void main() {
[[stage(fragment)]]
fn main() {
main_1();
return;
}
warning: DXIL.dll not found. Resulting DXIL will not be signed for use in release environments.
error: validation errors
tint_TECAbG:16: error: Loop must have break.
Validation failed.
error: loop does not exit

View File

@ -0,0 +1,25 @@
SKIP: FAILED
var<private> var_1 : u32;
fn main_1() {
var_1 = 0u;
loop {
var_1 = 1u;
var_1 = 2u;
continuing {
var_1 = 4u;
}
}
var_1 = 5u;
return;
}
[[stage(fragment)]]
fn main() {
main_1();
}
error: loop does not exit

View File

@ -0,0 +1,25 @@
SKIP: FAILED
var<private> var_1 : u32;
fn main_1() {
var_1 = 0u;
loop {
var_1 = 1u;
var_1 = 2u;
continuing {
var_1 = 4u;
}
}
var_1 = 5u;
return;
}
[[stage(fragment)]]
fn main() {
main_1();
}
error: loop does not exit

View File

@ -0,0 +1,25 @@
SKIP: FAILED
var<private> var_1 : u32;
fn main_1() {
var_1 = 0u;
loop {
var_1 = 1u;
var_1 = 2u;
continuing {
var_1 = 4u;
}
}
var_1 = 5u;
return;
}
[[stage(fragment)]]
fn main() {
main_1();
}
error: loop does not exit

View File

@ -1,12 +1,14 @@
SKIP: FAILED
static uint var_1 = 0u;
void main_1() {
var<private> var_1 : u32;
fn main_1() {
var_1 = 0u;
while (true) {
loop {
var_1 = 1u;
{
continuing {
var_1 = 4u;
}
}
@ -14,15 +16,9 @@ void main_1() {
return;
}
void main() {
[[stage(fragment)]]
fn main() {
main_1();
return;
}
warning: DXIL.dll not found. Resulting DXIL will not be signed for use in release environments.
error: validation errors
tint_U669Fi:15: error: Loop must have break.
Validation failed.
error: loop does not exit

View File

@ -0,0 +1,24 @@
SKIP: FAILED
var<private> var_1 : u32;
fn main_1() {
var_1 = 0u;
loop {
var_1 = 1u;
continuing {
var_1 = 4u;
}
}
var_1 = 5u;
return;
}
[[stage(fragment)]]
fn main() {
main_1();
}
error: loop does not exit

View File

@ -0,0 +1,24 @@
SKIP: FAILED
var<private> var_1 : u32;
fn main_1() {
var_1 = 0u;
loop {
var_1 = 1u;
continuing {
var_1 = 4u;
}
}
var_1 = 5u;
return;
}
[[stage(fragment)]]
fn main() {
main_1();
}
error: loop does not exit

View File

@ -0,0 +1,24 @@
SKIP: FAILED
var<private> var_1 : u32;
fn main_1() {
var_1 = 0u;
loop {
var_1 = 1u;
continuing {
var_1 = 4u;
}
}
var_1 = 5u;
return;
}
[[stage(fragment)]]
fn main() {
main_1();
}
error: loop does not exit

View File

@ -1,33 +1,30 @@
SKIP: FAILED
static uint var_1 = 0u;
void main_1() {
var<private> var_1 : u32;
fn main_1() {
var_1 = 0u;
while (true) {
loop {
var_1 = 1u;
var_1 = 2u;
switch(42u) {
case 40u: {
var_1 = 40u;
if (false) {
{
var_1 = 4u;
}
continue;
}
/* fallthrough */
fallthrough;
}
case 50u: {
var_1 = 50u;
break;
}
default: {
break;
}
}
var_1 = 3u;
{
continuing {
var_1 = 4u;
}
}
@ -35,15 +32,9 @@ void main_1() {
return;
}
void main() {
[[stage(fragment)]]
fn main() {
main_1();
return;
}
warning: DXIL.dll not found. Resulting DXIL will not be signed for use in release environments.
error: validation errors
tint_cTIG3E:36: error: Loop must have break.
Validation failed.
error: loop does not exit

View File

@ -0,0 +1,40 @@
SKIP: FAILED
var<private> var_1 : u32;
fn main_1() {
var_1 = 0u;
loop {
var_1 = 1u;
var_1 = 2u;
switch(42u) {
case 40u: {
var_1 = 40u;
if (false) {
continue;
}
fallthrough;
}
case 50u: {
var_1 = 50u;
}
default: {
}
}
var_1 = 3u;
continuing {
var_1 = 4u;
}
}
var_1 = 5u;
return;
}
[[stage(fragment)]]
fn main() {
main_1();
}
error: loop does not exit

View File

@ -0,0 +1,40 @@
SKIP: FAILED
var<private> var_1 : u32;
fn main_1() {
var_1 = 0u;
loop {
var_1 = 1u;
var_1 = 2u;
switch(42u) {
case 40u: {
var_1 = 40u;
if (false) {
continue;
}
fallthrough;
}
case 50u: {
var_1 = 50u;
}
default: {
}
}
var_1 = 3u;
continuing {
var_1 = 4u;
}
}
var_1 = 5u;
return;
}
[[stage(fragment)]]
fn main() {
main_1();
}
error: loop does not exit

View File

@ -0,0 +1,40 @@
SKIP: FAILED
var<private> var_1 : u32;
fn main_1() {
var_1 = 0u;
loop {
var_1 = 1u;
var_1 = 2u;
switch(42u) {
case 40u: {
var_1 = 40u;
if (false) {
continue;
}
fallthrough;
}
case 50u: {
var_1 = 50u;
}
default: {
}
}
var_1 = 3u;
continuing {
var_1 = 4u;
}
}
var_1 = 5u;
return;
}
[[stage(fragment)]]
fn main() {
main_1();
}
error: loop does not exit

View File

@ -1,10 +1,11 @@
SKIP: FAILED
static uint var_1 = 0u;
void main_1() {
var<private> var_1 : u32;
fn main_1() {
var_1 = 0u;
while (true) {
loop {
var_1 = 1u;
var_1 = 2u;
switch(42u) {
@ -12,23 +13,19 @@ void main_1() {
var_1 = 40u;
if (false) {
} else {
{
var_1 = 4u;
}
continue;
}
/* fallthrough */
fallthrough;
}
case 50u: {
var_1 = 50u;
break;
}
default: {
break;
}
}
var_1 = 3u;
{
continuing {
var_1 = 4u;
}
}
@ -36,15 +33,9 @@ void main_1() {
return;
}
void main() {
[[stage(fragment)]]
fn main() {
main_1();
return;
}
warning: DXIL.dll not found. Resulting DXIL will not be signed for use in release environments.
error: validation errors
tint_KckIVH:37: error: Loop must have break.
Validation failed.
error: loop does not exit

View File

@ -0,0 +1,41 @@
SKIP: FAILED
var<private> var_1 : u32;
fn main_1() {
var_1 = 0u;
loop {
var_1 = 1u;
var_1 = 2u;
switch(42u) {
case 40u: {
var_1 = 40u;
if (false) {
} else {
continue;
}
fallthrough;
}
case 50u: {
var_1 = 50u;
}
default: {
}
}
var_1 = 3u;
continuing {
var_1 = 4u;
}
}
var_1 = 5u;
return;
}
[[stage(fragment)]]
fn main() {
main_1();
}
error: loop does not exit

Some files were not shown because too many files have changed in this diff Show More