translate-c-2 fix switch range

master
Vexu 2019-12-20 11:35:21 +02:00
parent d172a7335c
commit daeb939210
No known key found for this signature in database
GPG Key ID: 59AEB8936E16A6AC
2 changed files with 5 additions and 5 deletions

View File

@ -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.* = .{

View File

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