From 9fa5058add7144384421c5dece36187a08c04619 Mon Sep 17 00:00:00 2001 From: Rangi Date: Sat, 22 Aug 2026 18:58:23 -0400 Subject: [PATCH] Correct error message for macro arg `\<-INT_MIN>` --- src/asm/lexer.cpp | 2 +- test/asm/negative-macro-args.err | 3 +-- test/asm/negative-macro-args.out | 2 +- test/asm/negative-shifted-macro-args.err | 6 ++---- test/asm/negative-shifted-macro-args.out | 1 + 5 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/asm/lexer.cpp b/src/asm/lexer.cpp index 4951118a..27b0b76f 100644 --- a/src/asm/lexer.cpp +++ b/src/asm/lexer.cpp @@ -542,7 +542,7 @@ static uint32_t readBracketedMacroArgNum() { } } uint32_t n = readNumber<10>(bumpChar(), nullptr); - if (n > INT32_MAX) { + if (n > INT32_MAX && !(negative && n == static_cast(INT32_MAX) + 1)) { error("Number in bracketed macro argument is too large"); return 0; } diff --git a/test/asm/negative-macro-args.err b/test/asm/negative-macro-args.err index c6ad7131..99175c0f 100644 --- a/test/asm/negative-macro-args.err +++ b/test/asm/negative-macro-args.err @@ -12,9 +12,8 @@ error: Macro argument `\<2147483647>` not defined at negative-macro-args.asm::mac(11) <- negative-macro-args.asm(21) error: Macro argument `\<-2147483648>` not defined at negative-macro-args.asm::mac(14) <- negative-macro-args.asm(21) -error: Number in bracketed macro argument is too large +error: Macro argument `\<-2147483648>` not defined at negative-macro-args.asm::mac(14) <- negative-macro-args.asm(21) - while expanding symbol `i` error: Macro argument `\<-2147483648>` not defined at negative-macro-args.asm::mac(15) <- negative-macro-args.asm(21) error: Number in bracketed macro argument is too large diff --git a/test/asm/negative-macro-args.out b/test/asm/negative-macro-args.out index 48c32e6b..53698db2 100644 --- a/test/asm/negative-macro-args.out +++ b/test/asm/negative-macro-args.out @@ -8,7 +8,7 @@ 0: == -8: == 2147483647: == --2147483648: == > +-2147483648: == 2147483648: == > -1: G == G 4294967295: G == > diff --git a/test/asm/negative-shifted-macro-args.err b/test/asm/negative-shifted-macro-args.err index 1ec467d3..3e127927 100644 --- a/test/asm/negative-shifted-macro-args.err +++ b/test/asm/negative-shifted-macro-args.err @@ -12,8 +12,6 @@ error: Macro argument `\1` not defined at negative-shifted-macro-args.asm::test(15) <- negative-shifted-macro-args.asm(22) error: Macro argument `\<-1>` not defined at negative-shifted-macro-args.asm::test(16) <- negative-shifted-macro-args.asm(22) -error: Number in bracketed macro argument is too large +error: Macro argument `\<-2147483648>` not defined at negative-shifted-macro-args.asm::test(19) <- negative-shifted-macro-args.asm(22) -error: syntax error, unexpected > - at negative-shifted-macro-args.asm::test(19) <- negative-shifted-macro-args.asm(22) -Assembly aborted with 9 errors +Assembly aborted with 8 errors diff --git a/test/asm/negative-shifted-macro-args.out b/test/asm/negative-shifted-macro-args.out index 4ae99772..60cf740c 100644 --- a/test/asm/negative-shifted-macro-args.out +++ b/test/asm/negative-shifted-macro-args.out @@ -11,3 +11,4 @@ $0 $A +