aboutsummaryrefslogtreecommitdiff
path: root/src/codegen.zig
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2021-11-21 19:39:32 -0700
committerAndrew Kelley <andrew@ziglang.org>2021-11-21 19:43:08 -0700
commit6afcaf4a08b6fb1cce0cdb2393fc1d4cd041509c (patch)
treebf4a17c51d53b720077e8315c5d0a38f20eba219 /src/codegen.zig
parent96e5f661bd34d98bba89bcb70c9db059aaf38641 (diff)
downloadzig-6afcaf4a08b6fb1cce0cdb2393fc1d4cd041509c.tar.gz
zig-6afcaf4a08b6fb1cce0cdb2393fc1d4cd041509c.zip
stage2: fix the build for 32-bit architectures
* Introduce a mechanism into Sema for emitting a compile error when an integer is too big and we need it to fit into a usize. * Add `@intCast` where necessary * link/MachO: fix an unnecessary allocation when all that was happening was appending zeroes to an ArrayList. * Add `error.Overflow` as a possible error to some codepaths, allowing usage of `math.intCast`. closes #9710
Diffstat (limited to 'src/codegen.zig')
-rw-r--r--src/codegen.zig4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/codegen.zig b/src/codegen.zig
index 0f13b43c36..3a74342adf 100644
--- a/src/codegen.zig
+++ b/src/codegen.zig
@@ -37,6 +37,7 @@ pub const Result = union(enum) {
pub const GenerateSymbolError = error{
OutOfMemory,
+ Overflow,
/// A Decl that this symbol depends on had a semantic analysis failure.
AnalysisFail,
};
@@ -289,7 +290,8 @@ pub fn generateSymbol(
const field_vals = typed_value.val.castTag(.@"struct").?.data;
_ = field_vals; // TODO write the fields for real
const target = bin_file.options.target;
- try code.writer().writeByteNTimes(0xaa, typed_value.ty.abiSize(target));
+ const abi_size = try math.cast(usize, typed_value.ty.abiSize(target));
+ try code.writer().writeByteNTimes(0xaa, abi_size);
return Result{ .appended = {} };
},
else => |t| {