Skip to content

Commit

Permalink
Parser: only warn for implicitly-unsigned integer literals for base 10
Browse files Browse the repository at this point in the history
  • Loading branch information
ehaas committed Oct 5, 2024
1 parent a824a68 commit 7ed4cb0
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/aro/Parser.zig
Original file line number Diff line number Diff line change
Expand Up @@ -8506,7 +8506,7 @@ fn fixedSizeInt(p: *Parser, base: u8, buf: []const u8, suffix: NumberSuffix, tok
return res;
}
const interned_val = try Value.int(val, p.comp);
if (suffix.isSignedInteger()) {
if (suffix.isSignedInteger() and base == 10) {
const max_int = try Value.maxInt(p.comp.types.intmax, p.comp);
if (interned_val.compare(.gt, max_int, p.comp)) {
try p.errTok(.implicitly_unsigned_literal, tok_i);
Expand Down
1 change: 1 addition & 0 deletions test/cases/implicitly unsigned literal.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
_Static_assert(-9223372036854775808LL > 0, "lhs should be unsigned");
long long x = 9223372036854775808LL;
_Static_assert(0xFFFFFFFFFFFFFFFF == 0xFFFFFFFFFFFFFFFE + 1, "");

#define EXPECTED_ERRORS \
"implicitly unsigned literal.c:1:17: warning: integer literal is too large to be represented in a signed integer type, interpreting as unsigned [-Wimplicitly-unsigned-literal]" \
Expand Down

0 comments on commit 7ed4cb0

Please sign in to comment.