translate-c: switch default should have an empty block not break

This commit is contained in:
Veikka Tuominen 2021-02-22 19:26:19 +02:00
parent ce9b3ee0f9
commit 011bc1b84f
No known key found for this signature in database
GPG Key ID: 59AEB8936E16A6AC
2 changed files with 8 additions and 1 deletions

View File

@ -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);
}

View File

@ -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;
\\ },