dawn-cmake/test/tint/statements/switch
Antonio Maiorano eab1f62629 tint/hlsl: for default-only switch, only emit condition if it has side-effects
This fixes edge-cases, like the condition expression being a type-cast,
which DXC apparently sees as a variable re-declaration. Example:

fn foo(x : f32) {
  switch (i32(x)) {
    default {
    }
  }
}

was emitted as HLSL:

void foo(float x) {
  int(x);
  do {
  } while (false);
}

The `int(x)` is seen as a re-declaration of `x` by DXC.

We fix this by only emitted the condition expression if it has
side-effects (which currently means it contains a call expression).

Bug: tint:1820
Change-Id: I7e4320fa09ea2d634c9e324cb0b752b0ee7dcde9
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/118161
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: James Price <jrprice@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
2023-02-01 15:46:34 +00:00
..
case_default.wgsl [WGSL] Allow default as a case selector 2022-10-19 15:55:02 +00:00
case_default.wgsl.expected.dxc.hlsl [WGSL] Allow default as a case selector 2022-10-19 15:55:02 +00:00
case_default.wgsl.expected.fxc.hlsl [WGSL] Allow default as a case selector 2022-10-19 15:55:02 +00:00
case_default.wgsl.expected.glsl [WGSL] Allow default as a case selector 2022-10-19 15:55:02 +00:00
case_default.wgsl.expected.msl [WGSL] Allow default as a case selector 2022-10-19 15:55:02 +00:00
case_default.wgsl.expected.spvasm [WGSL] Allow default as a case selector 2022-10-19 15:55:02 +00:00
case_default.wgsl.expected.wgsl [WGSL] Allow default as a case selector 2022-10-19 15:55:02 +00:00
case_default_mixed.wgsl [WGSL] Allow default as a case selector 2022-10-19 15:55:02 +00:00
case_default_mixed.wgsl.expected.dxc.hlsl [WGSL] Allow default as a case selector 2022-10-19 15:55:02 +00:00
case_default_mixed.wgsl.expected.fxc.hlsl [WGSL] Allow default as a case selector 2022-10-19 15:55:02 +00:00
case_default_mixed.wgsl.expected.glsl [WGSL] Allow default as a case selector 2022-10-19 15:55:02 +00:00
case_default_mixed.wgsl.expected.msl [WGSL] Allow default as a case selector 2022-10-19 15:55:02 +00:00
case_default_mixed.wgsl.expected.spvasm [WGSL] Allow default as a case selector 2022-10-19 15:55:02 +00:00
case_default_mixed.wgsl.expected.wgsl [WGSL] Allow default as a case selector 2022-10-19 15:55:02 +00:00
common.wgsl
common.wgsl.expected.dxc.hlsl tint/test-runner: Split expectations for FXC and DXC 2022-07-22 17:43:27 +00:00
common.wgsl.expected.fxc.hlsl tint/test-runner: Split expectations for FXC and DXC 2022-07-22 17:43:27 +00:00
common.wgsl.expected.glsl
common.wgsl.expected.msl
common.wgsl.expected.spvasm
common.wgsl.expected.wgsl
only_default_case.wgsl
only_default_case.wgsl.expected.dxc.hlsl tint/hlsl: for default-only switch, only emit condition if it has side-effects 2023-02-01 15:46:34 +00:00
only_default_case.wgsl.expected.fxc.hlsl tint/hlsl: for default-only switch, only emit condition if it has side-effects 2023-02-01 15:46:34 +00:00
only_default_case.wgsl.expected.glsl
only_default_case.wgsl.expected.msl
only_default_case.wgsl.expected.spvasm
only_default_case.wgsl.expected.wgsl