diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2023-06-20 16:41:58 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-06-20 16:41:58 -0700 |
| commit | b77679039fd40aa1693781f99ac89f2dc705e5c2 (patch) | |
| tree | e3a4d2e77f3e4e31b3c854a6ffe010f1cb35e8b5 /src/type.zig | |
| parent | 0f2339f55b2fa45a8af94c26a7ceb8377e3acfef (diff) | |
| parent | c205521aea01e332209a28e7518a787d1c1e8f26 (diff) | |
| download | zig-b77679039fd40aa1693781f99ac89f2dc705e5c2.tar.gz zig-b77679039fd40aa1693781f99ac89f2dc705e5c2.zip | |
Merge pull request #15415 from ehaas/c-char-signedness
Set `c_char` signedness based on the target
Diffstat (limited to 'src/type.zig')
| -rw-r--r-- | src/type.zig | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/type.zig b/src/type.zig index ac5305b3f4..bce97b65cb 100644 --- a/src/type.zig +++ b/src/type.zig @@ -2216,7 +2216,8 @@ pub const Type = struct { /// Returns true if and only if the type is a fixed-width, signed integer. pub fn isSignedInt(ty: Type, mod: *const Module) bool { return switch (ty.toIntern()) { - .c_char_type, .isize_type, .c_short_type, .c_int_type, .c_long_type, .c_longlong_type => true, + .c_char_type => mod.getTarget().charSignedness() == .signed, + .isize_type, .c_short_type, .c_int_type, .c_long_type, .c_longlong_type => true, else => switch (mod.intern_pool.indexToKey(ty.toIntern())) { .int_type => |int_type| int_type.signedness == .signed, else => false, @@ -2227,6 +2228,7 @@ pub const Type = struct { /// Returns true if and only if the type is a fixed-width, unsigned integer. pub fn isUnsignedInt(ty: Type, mod: *const Module) bool { return switch (ty.toIntern()) { + .c_char_type => mod.getTarget().charSignedness() == .unsigned, .usize_type, .c_ushort_type, .c_uint_type, .c_ulong_type, .c_ulonglong_type => true, else => switch (mod.intern_pool.indexToKey(ty.toIntern())) { .int_type => |int_type| int_type.signedness == .unsigned, @@ -2257,7 +2259,7 @@ pub const Type = struct { }, .usize_type => return .{ .signedness = .unsigned, .bits = target.ptrBitWidth() }, .isize_type => return .{ .signedness = .signed, .bits = target.ptrBitWidth() }, - .c_char_type => return .{ .signedness = .signed, .bits = target.c_type_bit_size(.char) }, + .c_char_type => return .{ .signedness = mod.getTarget().charSignedness(), .bits = target.c_type_bit_size(.char) }, .c_short_type => return .{ .signedness = .signed, .bits = target.c_type_bit_size(.short) }, .c_ushort_type => return .{ .signedness = .unsigned, .bits = target.c_type_bit_size(.ushort) }, .c_int_type => return .{ .signedness = .signed, .bits = target.c_type_bit_size(.int) }, |
