Add test case for 'loop over switch with continue inside.'

We didn't have a test case for this particular construct, but we will
emit special code to handle it when rewriting switch statements.

Change-Id: I7ac632f7bee348194940812c956c8a7df51ffaff
Bug: skia:12450
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/450477
Auto-Submit: John Stiles <johnstiles@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
This commit is contained in:
John Stiles 2021-09-20 11:28:59 -04:00 committed by SkCQ
parent 4f867cc201
commit 498bfa4a85
4 changed files with 503 additions and 428 deletions

View File

@ -113,6 +113,16 @@ bool switch_with_continue_in_loop() {
}
}
bool loop_with_continue_in_switch() {
for (int x=0; x<=10; ++x) {
switch (int(unknownInput)) {
case 1: continue;
default: return true;
}
}
return true;
}
bool switch_with_if_that_returns() {
switch (int(unknownInput)) {
case 1: if (unknownInput == 123) return true; else return true;
@ -144,6 +154,7 @@ half4 main(float2 coords) {
switch_fallthrough() &&
switch_fallthrough_twice() &&
switch_with_break_in_loop() &&
loop_with_continue_in_switch() &&
switch_with_continue_in_loop() &&
switch_with_if_that_returns() &&
switch_with_one_sided_if_then_fallthrough() ? colorGreen : colorRed;

File diff suppressed because it is too large Load Diff

View File

@ -105,6 +105,17 @@ bool switch_with_continue_in_loop_b() {
return true;
}
}
bool loop_with_continue_in_switch_b() {
for (int x = 0;x <= 10; ++x) {
switch (int(unknownInput)) {
case 1:
continue;
default:
return true;
}
}
return true;
}
bool switch_with_if_that_returns_b() {
switch (int(unknownInput)) {
case 1:
@ -122,5 +133,5 @@ bool switch_with_one_sided_if_then_fallthrough_b() {
}
}
vec4 main() {
return (((((((((((((((((true && return_on_both_sides_b()) && for_inside_body_b()) && after_for_body_b()) && for_with_double_sided_conditional_return_b()) && if_else_chain_b()) && conditional_inside_while_loop_b()) && inside_do_loop_b()) && inside_while_loop_b()) && after_do_loop_b()) && after_while_loop_b()) && switch_with_all_returns_b()) && switch_only_default_b()) && switch_fallthrough_b()) && switch_fallthrough_twice_b()) && switch_with_break_in_loop_b()) && switch_with_continue_in_loop_b()) && switch_with_if_that_returns_b()) && switch_with_one_sided_if_then_fallthrough_b() ? colorGreen : colorRed;
return ((((((((((((((((((true && return_on_both_sides_b()) && for_inside_body_b()) && after_for_body_b()) && for_with_double_sided_conditional_return_b()) && if_else_chain_b()) && conditional_inside_while_loop_b()) && inside_do_loop_b()) && inside_while_loop_b()) && after_do_loop_b()) && after_while_loop_b()) && switch_with_all_returns_b()) && switch_only_default_b()) && switch_fallthrough_b()) && switch_fallthrough_twice_b()) && switch_with_break_in_loop_b()) && loop_with_continue_in_switch_b()) && switch_with_continue_in_loop_b()) && switch_with_if_that_returns_b()) && switch_with_one_sided_if_then_fallthrough_b() ? colorGreen : colorRed;
}

View File

@ -113,6 +113,17 @@ bool switch_with_continue_in_loop_b(Uniforms _uniforms) {
return true;
}
}
bool loop_with_continue_in_switch_b(Uniforms _uniforms) {
for (int x = 0;x <= 10; ++x) {
switch (int(_uniforms.unknownInput)) {
case 1:
continue;
default:
return true;
}
}
return true;
}
bool switch_with_if_that_returns_b(Uniforms _uniforms) {
switch (int(_uniforms.unknownInput)) {
case 1:
@ -132,6 +143,6 @@ bool switch_with_one_sided_if_then_fallthrough_b(Uniforms _uniforms) {
fragment Outputs fragmentMain(Inputs _in [[stage_in]], constant Uniforms& _uniforms [[buffer(0)]], bool _frontFacing [[front_facing]], float4 _fragCoord [[position]]) {
Outputs _out;
(void)_out;
_out.sk_FragColor = (((((((((((((((((true && return_on_both_sides_b(_uniforms)) && for_inside_body_b()) && after_for_body_b()) && for_with_double_sided_conditional_return_b(_uniforms)) && if_else_chain_b(_uniforms)) && conditional_inside_while_loop_b(_uniforms)) && inside_do_loop_b()) && inside_while_loop_b()) && after_do_loop_b()) && after_while_loop_b()) && switch_with_all_returns_b(_uniforms)) && switch_only_default_b(_uniforms)) && switch_fallthrough_b(_uniforms)) && switch_fallthrough_twice_b(_uniforms)) && switch_with_break_in_loop_b(_uniforms)) && switch_with_continue_in_loop_b(_uniforms)) && switch_with_if_that_returns_b(_uniforms)) && switch_with_one_sided_if_then_fallthrough_b(_uniforms) ? _uniforms.colorGreen : _uniforms.colorRed;
_out.sk_FragColor = ((((((((((((((((((true && return_on_both_sides_b(_uniforms)) && for_inside_body_b()) && after_for_body_b()) && for_with_double_sided_conditional_return_b(_uniforms)) && if_else_chain_b(_uniforms)) && conditional_inside_while_loop_b(_uniforms)) && inside_do_loop_b()) && inside_while_loop_b()) && after_do_loop_b()) && after_while_loop_b()) && switch_with_all_returns_b(_uniforms)) && switch_only_default_b(_uniforms)) && switch_fallthrough_b(_uniforms)) && switch_fallthrough_twice_b(_uniforms)) && switch_with_break_in_loop_b(_uniforms)) && loop_with_continue_in_switch_b(_uniforms)) && switch_with_continue_in_loop_b(_uniforms)) && switch_with_if_that_returns_b(_uniforms)) && switch_with_one_sided_if_then_fallthrough_b(_uniforms) ? _uniforms.colorGreen : _uniforms.colorRed;
return _out;
}