dawn-cmake/test/tint/statements
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
..
assign Tint/transform: make AddBlockAttribute always do wrapping if possible 2022-11-02 02:25:38 +00:00
compound_assign tint/spir-v backend: emit OpSRem instead of OpSMod for remainder 2023-01-31 19:09:05 +00:00
decrement tint/transform: Implement div / mod polyfill 2022-11-09 22:04:11 +00:00
discard tint: Fix DemoteToHelper for atomicCmpXchgWeak 2022-11-14 20:30:38 +00:00
for tint/transform: fix PromoteInitializersToLet for constant expressions 2022-12-09 12:34:36 +00:00
increment tint/transform: Implement div / mod polyfill 2022-11-09 22:04:11 +00:00
switch tint/hlsl: for default-only switch, only emit condition if it has side-effects 2023-02-01 15:46:34 +00:00