From f6c49fdb2cc7ead1943d944097220cedd142792f Mon Sep 17 00:00:00 2001 From: sriramm-nv <85252063+sriramm-nv@users.noreply.github.com> Date: Wed, 3 Apr 2024 15:10:16 -0700 Subject: Fix assertions due to malformed switch statements (#3858) * Fix assertions due to malformed switch statements Fixes the issue #2955 * Checks for multiple case statements with same values * Checks for multiple default cases * Constant-folds case exprs into an Integer value * fix the comments, and updated error code * one-line comment on diagnostic code --- tests/diagnostics/switch-multiple-defaults.slang | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 tests/diagnostics/switch-multiple-defaults.slang (limited to 'tests/diagnostics/switch-multiple-defaults.slang') diff --git a/tests/diagnostics/switch-multiple-defaults.slang b/tests/diagnostics/switch-multiple-defaults.slang new file mode 100644 index 000000000..bf164dd57 --- /dev/null +++ b/tests/diagnostics/switch-multiple-defaults.slang @@ -0,0 +1,14 @@ +//TEST:SIMPLE(filecheck=CHECK): + +// Test to evaluate the behavior of unreachable code blocks within a switch statement. A switch statement with multiple default cases is not allowed and should throw an error + +void test() +{ + switch (0) + { + default: break; + // CHECK: ([[# @LINE+1]]): error 30600: {{.*}} + default: break; + } + return; +} -- cgit v1.2.3