| author | |
| committer | |
| log | 8238d4b33585a715c58ab559cd001dd3ea1db55b |
| tree | f1d659627f00427fdaecaaacb80806d033a2501d |
| parent | 8df84cce8b68339c332d30213efe90cdc833d059 |
Commit 052079c99455d01312d377d72fa1b8b5c0b22aad surfaced two issues with
the generated C code:
- renderInt128() contained a seemingly unnecessary assertion to verify
that the high 64 bits of the number were nonzero, dating back to
9bf1681990fe87a6b2e5fc644a89f1aece304579. I removed it.
- renderValue() didn't have any special handling for undefined structs,
falling back to printing "{}" which generated invalid expressions
such as "return {}" for functions returning structs, whereas
"return (S){}" is the correct form. I changed it accordingly.
At the same time I'm reenabling the relevant tests.6 files changed, 5 insertions(+), 7 deletions(-)
src/codegen/c.zig+5-1| ... | ... | @@ -433,7 +433,6 @@ pub const DeclGen = struct { |
| 433 | 433 | if (is_signed) try writer.writeAll("(int128_t)"); |
| 434 | 434 | if (is_neg) try writer.writeByte('-'); |
| 435 | 435 | |
| 436 | assert(high > 0); | |
| 437 | 436 | try writer.print("(((uint128_t)0x{x}u<<64)", .{high}); |
| 438 | 437 | |
| 439 | 438 | if (low > 0) |
| ... | ... | @@ -572,6 +571,11 @@ pub const DeclGen = struct { |
| 572 | 571 | 64 => return writer.writeAll("(void *)0xaaaaaaaaaaaaaaaa"), |
| 573 | 572 | else => unreachable, |
| 574 | 573 | }, |
| 574 | .Struct => { | |
| 575 | try writer.writeByte('('); | |
| 576 | try dg.renderTypecast(writer, ty); | |
| 577 | return writer.writeAll("){0xaa}"); | |
| 578 | }, | |
| 575 | 579 | else => { |
| 576 | 580 | // This should lower to 0xaa bytes in safe modes, and for unsafe modes should |
| 577 | 581 | // lower to leaving variables uninitialized (that might need to be implemented |
test/behavior/eval.zig-1| ... | ... | @@ -443,7 +443,6 @@ fn copyWithPartialInline(s: []u32, b: []u8) void { |
| 443 | 443 | test "binary math operator in partially inlined function" { |
| 444 | 444 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO |
| 445 | 445 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO |
| 446 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO | |
| 447 | 446 | |
| 448 | 447 | var s: [4]u32 = undefined; |
| 449 | 448 | var b: [16]u8 = undefined; |
test/behavior/fn.zig-1| ... | ... | @@ -75,7 +75,6 @@ test "return inner function which references comptime variable of outer function |
| 75 | 75 | } |
| 76 | 76 | |
| 77 | 77 | test "discard the result of a function that returns a struct" { |
| 78 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO | |
| 79 | 78 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; |
| 80 | 79 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; |
| 81 | 80 |
test/behavior/for.zig-1| ... | ... | @@ -69,7 +69,6 @@ test "basic for loop" { |
| 69 | 69 | if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; |
| 70 | 70 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; |
| 71 | 71 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; |
| 72 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; | |
| 73 | 72 | |
| 74 | 73 | const expected_result = [_]u8{ 9, 8, 7, 6, 0, 1, 2, 3 } ** 3; |
| 75 | 74 |
test/behavior/int128.zig-1| ... | ... | @@ -46,7 +46,6 @@ test "int128" { |
| 46 | 46 | if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; // TODO |
| 47 | 47 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO |
| 48 | 48 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO |
| 49 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO | |
| 50 | 49 | |
| 51 | 50 | var buff: i128 = -1; |
| 52 | 51 | try expect(buff < 0 and (buff + 1) == 0); |
test/behavior/slice.zig-2| ... | ... | @@ -74,8 +74,6 @@ fn assertLenIsZero(msg: []const u8) !void { |
| 74 | 74 | } |
| 75 | 75 | |
| 76 | 76 | test "access len index of sentinel-terminated slice" { |
| 77 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO | |
| 78 | ||
| 79 | 77 | const S = struct { |
| 80 | 78 | fn doTheTest() !void { |
| 81 | 79 | var slice: [:0]const u8 = "hello"; |