translate-c: switch default should have an empty block not break
This commit is contained in:
@@ -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;
|
||||
\\ },
|
||||
|
||||
Reference in New Issue
Block a user