From 7ed4cb0896d8d05ef7b3f7d6337e08ac05759d5d Mon Sep 17 00:00:00 2001 From: Evan Haas Date: Sat, 5 Oct 2024 13:47:02 -0700 Subject: [PATCH] Parser: only warn for implicitly-unsigned integer literals for base 10 --- src/aro/Parser.zig | 2 +- test/cases/implicitly unsigned literal.c | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/aro/Parser.zig b/src/aro/Parser.zig index 9e3a387b..21df6625 100644 --- a/src/aro/Parser.zig +++ b/src/aro/Parser.zig @@ -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); diff --git a/test/cases/implicitly unsigned literal.c b/test/cases/implicitly unsigned literal.c index e1d5f7bd..7d5c0aca 100644 --- a/test/cases/implicitly unsigned literal.c +++ b/test/cases/implicitly unsigned literal.c @@ -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]" \