| author | |
| committer | |
| log | d83698ab54947c79c90d54c27e5a6d52c12fc52f |
| tree | 3497e2421bf78a82279796c4a3a1dfdfa3e0e720 |
| parent | f3ee10b4547bf5f03a4728b0d48b22bad6c9a5b1 |
| signature |
3 files changed, 18 insertions(+), 7 deletions(-)
src/translate_c.zig+7-6| ... | ... | @@ -2374,6 +2374,9 @@ fn transSwitchProngStmtInline( |
| 2374 | 2374 | const result = try transStmt(c, &block.base, sub, .unused); |
| 2375 | 2375 | assert(result.tag() != .declaration); |
| 2376 | 2376 | try block.statements.append(result); |
| 2377 | if (result.isNoreturn(true)) { | |
| 2378 | return; | |
| 2379 | } | |
| 2377 | 2380 | }, |
| 2378 | 2381 | .DefaultStmtClass => { |
| 2379 | 2382 | var sub = @ptrCast(*const clang.DefaultStmt, it[0]).getSubStmt(); |
| ... | ... | @@ -2385,14 +2388,12 @@ fn transSwitchProngStmtInline( |
| 2385 | 2388 | const result = try transStmt(c, &block.base, sub, .unused); |
| 2386 | 2389 | assert(result.tag() != .declaration); |
| 2387 | 2390 | try block.statements.append(result); |
| 2391 | if (result.isNoreturn(true)) { | |
| 2392 | return; | |
| 2393 | } | |
| 2388 | 2394 | }, |
| 2389 | 2395 | .CompoundStmtClass => { |
| 2390 | const compound_stmt = @ptrCast(*const clang.CompoundStmt, it[0]); | |
| 2391 | var child_block = try Scope.Block.init(c, &block.base, false); | |
| 2392 | defer child_block.deinit(); | |
| 2393 | ||
| 2394 | try transCompoundStmtInline(c, compound_stmt, &child_block); | |
| 2395 | const result = try child_block.complete(c); | |
| 2396 | const result = try transCompoundStmt(c, &block.base, @ptrCast(*const clang.CompoundStmt, it[0])); | |
| 2396 | 2397 | try block.statements.append(result); |
| 2397 | 2398 | if (result.isNoreturn(true)) { |
| 2398 | 2399 | return; |
src/translate_c/ast.zig+1-1| ... | ... | @@ -401,7 +401,7 @@ pub const Node = extern union { |
| 401 | 401 | return true; |
| 402 | 402 | }, |
| 403 | 403 | .@"return", .return_void => return true, |
| 404 | .break_val, .@"break" => if (break_counts) return true, | |
| 404 | .@"break" => if (break_counts) return true, | |
| 405 | 405 | else => {}, |
| 406 | 406 | } |
| 407 | 407 | return false; |
test/translate_c.zig+10| ... | ... | @@ -2047,6 +2047,10 @@ pub fn addCases(cases: *tests.TranslateCContext) void { |
| 2047 | 2047 | \\ res = 3 * i; |
| 2048 | 2048 | \\ break; |
| 2049 | 2049 | \\ break; |
| 2050 | \\ case 7: { | |
| 2051 | \\ res = 7; | |
| 2052 | \\ break; | |
| 2053 | \\ } | |
| 2050 | 2054 | \\ case 4: |
| 2051 | 2055 | \\		case 5: |
| 2052 | 2056 | \\ res = 69; |
| ... | ... | @@ -2079,6 +2083,12 @@ pub fn addCases(cases: *tests.TranslateCContext) void { |
| 2079 | 2083 | \\ else => { |
| 2080 | 2084 | \\ res = @as(c_int, 3) * i; |
| 2081 | 2085 | \\ }, |
| 2086 | \\ @as(c_int, 7) => { | |
| 2087 | \\ { | |
| 2088 | \\ res = 7; | |
| 2089 | \\ break; | |
| 2090 | \\ } | |
| 2091 | \\ }, | |
| 2082 | 2092 | \\ @as(c_int, 4), @as(c_int, 5) => { |
| 2083 | 2093 | \\ res = 69; |
| 2084 | 2094 | \\ { |