aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDaniele Cocca <daniele.cocca@gmail.com>2022-03-28 21:30:07 +0100
committerAndrew Kelley <andrew@ziglang.org>2022-03-29 02:28:20 -0400
commit8238d4b33585a715c58ab559cd001dd3ea1db55b (patch)
treef1d659627f00427fdaecaaacb80806d033a2501d /src
parent8df84cce8b68339c332d30213efe90cdc833d059 (diff)
downloadzig-8238d4b33585a715c58ab559cd001dd3ea1db55b.tar.gz
zig-8238d4b33585a715c58ab559cd001dd3ea1db55b.zip
CBE: fix C output after PR #11302, reenable tests
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.
Diffstat (limited to 'src')
-rw-r--r--src/codegen/c.zig6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/codegen/c.zig b/src/codegen/c.zig
index 84bb3a211b..38a105c172 100644
--- a/src/codegen/c.zig
+++ b/src/codegen/c.zig
@@ -433,7 +433,6 @@ pub const DeclGen = struct {
if (is_signed) try writer.writeAll("(int128_t)");
if (is_neg) try writer.writeByte('-');
- assert(high > 0);
try writer.print("(((uint128_t)0x{x}u<<64)", .{high});
if (low > 0)
@@ -572,6 +571,11 @@ pub const DeclGen = struct {
64 => return writer.writeAll("(void *)0xaaaaaaaaaaaaaaaa"),
else => unreachable,
},
+ .Struct => {
+ try writer.writeByte('(');
+ try dg.renderTypecast(writer, ty);
+ return writer.writeAll("){0xaa}");
+ },
else => {
// This should lower to 0xaa bytes in safe modes, and for unsafe modes should
// lower to leaving variables uninitialized (that might need to be implemented