Check for overflow in fixed-point precision suffix (#1918)

Fixes #1917
This commit is contained in:
Rangi
2026-04-07 17:06:54 -04:00
committed by GitHub
parent bcff14b596
commit 9b4b4a581b
10 changed files with 60 additions and 36 deletions
+2
View File
@@ -21,3 +21,5 @@ def q24 = 1.25q.24
def qerr = 1.25q32
println "{q0f:qerr}"
def qerr = 1.25q264
println "{q999f:qerr}"
+5 -1
View File
@@ -2,4 +2,8 @@ error: Fixed-point constant precision must be between 1 and 31
at fixed-point-precision.asm(22)
error: Fixed-point constant precision 0 invalid, defaulting to 16
at fixed-point-precision.asm(23)
Assembly aborted with 2 errors
error: Fixed-point constant precision must be between 1 and 31
at fixed-point-precision.asm(24)
error: Fixed-point constant precision 999 invalid, defaulting to 16
at fixed-point-precision.asm(25)
Assembly aborted with 4 errors
+1
View File
@@ -7,3 +7,4 @@
0.00488q16 1.25000q16 320.00000q16
Q8 $140 Q16 $14000 Q24 $1400000
1.25000
1.25000
+6 -3
View File
@@ -6,6 +6,12 @@ println 12.34_q.5
println 1_2.3_4_q15
println 1.q2
; warning
println 1.000_000_000_000_001
println 1.999_999_999_999_999
println 1.000_000_000_000_001q16
println 1.999_999_999_999_999q.16
; bad
println 12.34q0
println 12.34q_15 ; lexes as `12.34q` (invalid) then symbol `_15`
@@ -14,6 +20,3 @@ println 1_.2
println 1._2
println 1.__2
println 1.2q
println 1.999_999_999_999_999
println 1.999_999_999_999_999q16
println 1.999_999_999_999_999q.16
+18 -16
View File
@@ -1,25 +1,27 @@
error: Fixed-point constant precision must be between 1 and 31
warning: Fixed-point constant has too many fractional digits [-Wlarge-constant]
at fixed-point-syntax.asm(10)
error: Invalid fixed-point constant, no digits after 'q'
warning: Fixed-point constant has too many fractional digits [-Wlarge-constant]
at fixed-point-syntax.asm(11)
error: syntax error, unexpected symbol
at fixed-point-syntax.asm(11)
error: syntax error, unexpected symbol
warning: Fixed-point constant has too many fractional digits [-Wlarge-constant]
at fixed-point-syntax.asm(12)
error: Invalid integer constant, trailing '_'
warning: Fixed-point constant has too many fractional digits [-Wlarge-constant]
at fixed-point-syntax.asm(13)
error: Invalid fixed-point constant, '_' after '.'
at fixed-point-syntax.asm(14)
error: Invalid fixed-point constant, '_' after '.'
at fixed-point-syntax.asm(15)
error: Invalid fixed-point constant, '_' after another '_'
at fixed-point-syntax.asm(15)
error: Invalid fixed-point constant, no digits after 'q'
error: Fixed-point constant precision must be between 1 and 31
at fixed-point-syntax.asm(16)
warning: Precision of fixed-point constant is too large [-Wlarge-constant]
error: Invalid fixed-point constant, no digits after 'q'
at fixed-point-syntax.asm(17)
warning: Precision of fixed-point constant is too large [-Wlarge-constant]
error: syntax error, unexpected symbol
at fixed-point-syntax.asm(17)
error: syntax error, unexpected symbol
at fixed-point-syntax.asm(18)
warning: Precision of fixed-point constant is too large [-Wlarge-constant]
error: Invalid integer constant, trailing '_'
at fixed-point-syntax.asm(19)
error: Invalid fixed-point constant, '_' after '.'
at fixed-point-syntax.asm(20)
error: Invalid fixed-point constant, '_' after '.'
at fixed-point-syntax.asm(21)
error: Invalid fixed-point constant, '_' after another '_'
at fixed-point-syntax.asm(21)
error: Invalid fixed-point constant, no digits after 'q'
at fixed-point-syntax.asm(22)
Assembly aborted with 9 errors
+4 -3
View File
@@ -4,11 +4,12 @@ $4D2915B
$18B
$62B85
$4
$10000
$10000
$10000
$10000
$C570A
$13333
$13333
$13333
$13333
$10000
$10000
$10000
+1 -1
View File
@@ -1,6 +1,6 @@
error: Fractional width 99999999 too long, limiting to 255
at interpolation-overflow.asm(4)
warning: Precision of fixed-point constant is too large [-Wlarge-constant]
warning: Fixed-point constant has too many fractional digits [-Wlarge-constant]
at interpolation-overflow.asm(4)
while expanding symbol `x`
error: `\1` cannot be used outside of a macro
+1 -1
View File
@@ -16,7 +16,7 @@ warning: Integer constant is too large [-Wlarge-constant]
at invalid-numbers.asm::try(2) <- invalid-numbers.asm(20)
warning: Integer constant is too large [-Wlarge-constant]
at invalid-numbers.asm::try(2) <- invalid-numbers.asm(21)
warning: Graphics constant is too large; only first 8 pixels considered [-Wlarge-constant]
warning: Graphics constant has too many digits; only first 8 pixels considered [-Wlarge-constant]
at invalid-numbers.asm::try(2) <- invalid-numbers.asm(22)
warning: Magnitude of fixed-point constant is too large [-Wlarge-constant]
at invalid-numbers.asm::try(2) <- invalid-numbers.asm(23)
+1 -1
View File
@@ -4,5 +4,5 @@ warning: Division of -2147483648 by -1 yields -2147483648 [-Wdiv]
at overflow.asm(24)
warning: Integer constant is too large [-Wlarge-constant]
at overflow.asm(44)
warning: Graphics constant is too large; only first 8 pixels considered [-Wlarge-constant]
warning: Graphics constant has too many digits; only first 8 pixels considered [-Wlarge-constant]
at overflow.asm(47)