Skip to content

Commit

Permalink
Add consitency and test fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
wrongnull committed Jul 13, 2024
1 parent 81ce487 commit 89f29e0
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 16 deletions.
19 changes: 5 additions & 14 deletions src/aro/Type.zig
Original file line number Diff line number Diff line change
Expand Up @@ -1616,9 +1616,6 @@ pub const Builder = struct {
.int128 => "__int128",
.sint128 => "signed __int128",
.uint128 => "unsigned __int128",
.bit_int => "_BitInt",
.sbit_int => "signed _BitInt",
.ubit_int => "unsigned _BitInt",
.complex_char => "_Complex char",
.complex_schar => "_Complex signed char",
.complex_uchar => "_Complex unsigned char",
Expand Down Expand Up @@ -1648,9 +1645,6 @@ pub const Builder = struct {
.complex_int128 => "_Complex __int128",
.complex_sint128 => "_Complex signed __int128",
.complex_uint128 => "_Complex unsigned __int128",
.complex_bit_int => "_Complex _BitInt",
.complex_sbit_int => "_Complex signed _BitInt",
.complex_ubit_int => "_Complex unsigned _BitInt",

.fp16 => "__fp16",
.float16 => "_Float16",
Expand Down Expand Up @@ -2486,8 +2480,8 @@ fn printPrologue(ty: Type, mapper: StringInterner.TypeMapper, langopts: LangOpts
_ = try elem_ty.printPrologue(mapper, langopts, w);
try w.writeAll("' values)");
},
.bit_int => try w.print("{s}_BitInt({d})", .{ if (ty.data.int.signedness == .unsigned) "unsigned " else "", ty.data.int.bits }),
.complex_bit_int => try w.print("_Complex {s}_BitInt({d})", .{ if (ty.data.int.signedness == .unsigned) "unsigned " else "", ty.data.int.bits }),
.bit_int => try w.print("{s} _BitInt({d})", .{ @tagName(ty.data.int.signedness), ty.data.int.bits }),
.complex_bit_int => try w.print("_Complex {s} _BitInt({d})", .{ @tagName(ty.data.int.signedness), ty.data.int.bits }),
else => try w.writeAll(Builder.fromType(ty).str(langopts).?),
}
return true;
Expand Down Expand Up @@ -2646,12 +2640,9 @@ pub fn dump(ty: Type, mapper: StringInterner.TypeMapper, langopts: LangOpts, w:
try ty.data.attributed.base.dump(mapper, langopts, w);
try w.writeAll(")");
},
else => {
try w.writeAll(Builder.fromType(ty).str(langopts).?);
if (ty.specifier == .bit_int or ty.specifier == .complex_bit_int) {
try w.print("({d})", .{ty.data.int.bits});
}
},
.bit_int => try w.print("{s} _BitInt({d})", .{ @tagName(ty.data.int.signedness), ty.data.int.bits }),
.complex_bit_int => try w.print("_Complex {s} _BitInt({d})", .{ @tagName(ty.data.int.signedness), ty.data.int.bits }),
else => try w.writeAll(Builder.fromType(ty).str(langopts).?),
}
}

Expand Down
2 changes: 1 addition & 1 deletion test/cases/_BitInt change size.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
_BitInt(10) x = 1.2;
_Complex unsigned _BitInt(10) y = 1.2;

#define EXPECTED_ERRORS "_BitInt change size.c:1:17: warning: implicit conversion from 'double' to '_BitInt(10)' changes value from 1.2 to 1 [-Wfloat-conversion]"\
#define EXPECTED_ERRORS "_BitInt change size.c:1:17: warning: implicit conversion from 'double' to 'signed _BitInt(10)' changes value from 1.2 to 1 [-Wfloat-conversion]"\
"_BitInt change size.c:2:35: warning: implicit conversion from 'double' to '_Complex unsigned _BitInt(10)' changes value from 1.2 to 1 [-Wfloat-conversion]"
2 changes: 1 addition & 1 deletion test/cases/_BitInt.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,5 @@ _Static_assert(sizeof(_BitInt(65535)) == 8192, "");
"_BitInt.c:18:25: warning: '_BitInt' suffix for literals is a C23 extension [-Wc23-extensions]" \
"_BitInt.c:18:25: warning: '_BitInt' suffix for literals is a C23 extension [-Wc23-extensions]" \
"_BitInt.c:22:10: error: expected ';', found 'a character literal'" \
"_BitInt.c:27:5: error: enumerator value is not representable in the underlying type '_BitInt'" \
"_BitInt.c:27:5: error: enumerator value is not representable in the underlying type 'signed _BitInt(512)'" \

0 comments on commit 89f29e0

Please sign in to comment.