translate-c-2 fix switch range
parent
d172a7335c
commit
daeb939210
|
@ -1945,7 +1945,7 @@ fn transCase(
|
|||
const expr = if (ZigClangCaseStmt_getRHS(stmt)) |rhs| blk: {
|
||||
const lhs_node = try transExpr(rp, scope, ZigClangCaseStmt_getLHS(stmt), .used, .r_value);
|
||||
const ellips = try appendToken(rp.c, .Ellipsis3, "...");
|
||||
const rhs_node = try transExpr(rp, scope, ZigClangCaseStmt_getLHS(stmt), .used, .r_value);
|
||||
const rhs_node = try transExpr(rp, scope, rhs, .used, .r_value);
|
||||
|
||||
const node = try rp.c.a().create(ast.Node.InfixOp);
|
||||
node.* = .{
|
||||
|
|
|
@ -1286,12 +1286,12 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
|
|||
\\ switch (i) {
|
||||
\\ case 0:
|
||||
\\ res = 1;
|
||||
\\ case 1:
|
||||
\\ case 1 ... 3:
|
||||
\\ res = 2;
|
||||
\\ default:
|
||||
\\ res = 3 * i;
|
||||
\\ break;
|
||||
\\ case 2:
|
||||
\\ case 4:
|
||||
\\ res = 5;
|
||||
\\ }
|
||||
\\}
|
||||
|
@ -1306,9 +1306,9 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
|
|||
\\ __case_0: {
|
||||
\\ switch (i) {
|
||||
\\ 0 => break :__case_0,
|
||||
\\ 1 => break :__case_1,
|
||||
\\ 1...3 => break :__case_1,
|
||||
\\ else => break :__default,
|
||||
\\ 2 => break :__case_2,
|
||||
\\ 4 => break :__case_2,
|
||||
\\ }
|
||||
\\ }
|
||||
\\ res = 1;
|
||||
|
|
Loading…
Reference in New Issue