mirror of
https://github.com/ziglang/zig.git
synced 2025-12-25 15:43:06 +00:00
translate-c: switch default should have an empty block not break
This commit is contained in:
parent
ce9b3ee0f9
commit
011bc1b84f
@ -2276,7 +2276,7 @@ fn transSwitch(
|
||||
}
|
||||
|
||||
if (!has_default) {
|
||||
const else_prong = try Tag.switch_else.create(c.arena, Tag.@"break".init());
|
||||
const else_prong = try Tag.switch_else.create(c.arena, Tag.empty_block.init());
|
||||
try cases.append(else_prong);
|
||||
}
|
||||
|
||||
|
||||
@ -2055,6 +2055,9 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
|
||||
\\ return;
|
||||
\\ }
|
||||
\\ case 6:
|
||||
\\ switch (res) {
|
||||
\\ case 9: break;
|
||||
\\ }
|
||||
\\ res = 1;
|
||||
\\ return;
|
||||
\\ }
|
||||
@ -2084,6 +2087,10 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
|
||||
\\ }
|
||||
\\ },
|
||||
\\ @as(c_int, 6) => {
|
||||
\\ switch (res) {
|
||||
\\ @as(c_int, 9) => {},
|
||||
\\ else => {},
|
||||
\\ }
|
||||
\\ res = 1;
|
||||
\\ return;
|
||||
\\ },
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user