Skip to content

Commit

Permalink
Parser: use correct token for division overflow message
Browse files Browse the repository at this point in the history
  • Loading branch information
ehaas committed Apr 25, 2024
1 parent 82de1f0 commit fd1218e
Show file tree
Hide file tree
Showing 2 changed files with 5 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 @@ -6648,7 +6648,7 @@ fn mulExpr(p: *Parser) Error!Result {
lhs.ty.signedness(p.comp) != .unsigned) try p.errOverflow(mul.?, lhs);
} else if (div != null) {
if (try lhs.val.div(lhs.val, rhs.val, lhs.ty, p.comp) and
lhs.ty.signedness(p.comp) != .unsigned) try p.errOverflow(mul.?, lhs);
lhs.ty.signedness(p.comp) != .unsigned) try p.errOverflow(div.?, lhs);
} else {
var res = try Value.rem(lhs.val, rhs.val, lhs.ty, p.comp);
if (res.opt_ref == .none) {
Expand Down
4 changes: 4 additions & 0 deletions test/cases/arithmetic overflow.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,7 @@ _Static_assert(0x00000000 - 0x00000001 == 0xFFFFFFFF, "");
_Static_assert(0x80000000 * 2 == 0, "");
_Static_assert(2 * 0x80000000 == 0, "");
_Static_assert(sizeof(int) != 4 || ((unsigned)(-1) << 1) == 0xFFFFFFFFU - 1, "");
_Static_assert((-9223372036854775807LL - 1LL) / -1 != 0, "failed");

#define EXPECTED_ERRORS "arithmetic overflow.c:8:47: warning: overflow in expression; result is '9223372036854775808' [-Winteger-overflow]" \

0 comments on commit fd1218e

Please sign in to comment.