-
-
Notifications
You must be signed in to change notification settings - Fork 606
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix issue 11051 - Unmatched case in a final switch should throw in bo…
…th release and non-release mode (#14841) * Fix issue 11051 Keep a HALT instruction in a final switch statement if the function is @safe and -release mode is enabled. * @System -release test should also be non-zero * don't suppress test errors * Remove unreported error line * Disable core dumps Co-authored-by: Andrej Mitrovic <[email protected]>
- Loading branch information
1 parent
2e196ae
commit 49771d7
Showing
3 changed files
with
60 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
module test11051; | ||
|
||
version (Safe) | ||
{ | ||
void main() @safe | ||
{ | ||
enum E { A, B } | ||
E e = cast(E)-1; | ||
|
||
final switch (e) | ||
{ | ||
case E.A: break; | ||
case E.B: break; | ||
} | ||
} | ||
} | ||
else | ||
{ | ||
void main() | ||
{ | ||
enum E { A, B } | ||
E e = cast(E)-1; | ||
|
||
final switch (e) | ||
{ | ||
case E.A: break; | ||
case E.B: break; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#!/usr/bin/env bash | ||
|
||
# tests various @safe behavior for final switches in | ||
# -release and non-release builds | ||
|
||
src_file=runnable/extra-files/test11051.d | ||
|
||
die() | ||
{ | ||
echo "test_safe_final_switch.sh error: test #$1 failed" | ||
exit 1 | ||
} | ||
|
||
# some tests cause a core dump rather than throwing an Error | ||
ulimit -c 0 | ||
|
||
# returns 1 (failure) | ||
$DMD -run ${src_file} 2> /dev/null && die 1 | ||
|
||
# returns 1 (failure) | ||
$DMD -release -run ${src_file} 2> /dev/null && die 2 | ||
|
||
# returns 1 (failure) | ||
$DMD -version=Safe -run ${src_file} 2> /dev/null && die 3 | ||
|
||
# returns 1 (failure) | ||
$DMD -release -version=Safe -run ${src_file} 2> /dev/null && die 4 | ||
|
||
exit 0 |