ref: 106ad30e5a02f60037fd1d99d26866b4820a8197
parent: a1107fc5cfa552f9e1958de688f82aa5129adbcd
author: Rangi <35663410+Rangi42@users.noreply.github.com>
date: Sat Oct 1 13:32:34 EDT 2022
Allow fixed-point constants to have unsigned range (#1084) For example with Q.4, $F0 is 15.0, which no longer warns
--- a/src/asm/lexer.c
+++ b/src/asm/lexer.c
@@ -1179,7 +1179,7 @@
precision = fixPrecision;
}
- if (integer >= ((uint32_t)1 << (precision - 1)))
+ if (integer >= ((uint64_t)1 << precision))
warning(WARNING_LARGE_CONSTANT, "Magnitude of fixed-point constant is too large\n");
// Cast to unsigned avoids undefined overflow behavior
--- /dev/null
+++ b/test/asm/fixed-point-magnitude.asm
@@ -1,0 +1,13 @@
+OPT Q.4
+println 1.0
+println -1.0
+println 0.0625
+println -0.0625
+println 7.25
+println -7.25
+println 12.25
+println -12.25
+println 15.9375
+println -15.9375
+println 20.0
+println -20.0
--- /dev/null
+++ b/test/asm/fixed-point-magnitude.err
@@ -1,0 +1,4 @@
+warning: fixed-point-magnitude.asm(12): [-Wlarge-constant]
+ Magnitude of fixed-point constant is too large
+warning: fixed-point-magnitude.asm(13): [-Wlarge-constant]
+ Magnitude of fixed-point constant is too large
--- /dev/null
+++ b/test/asm/fixed-point-magnitude.out
@@ -1,0 +1,12 @@
+$10
+$FFFFFFF0
+$1
+$FFFFFFFF
+$74
+$FFFFFF8C
+$C4
+$FFFFFF3C
+$FF
+$FFFFFF01
+$140
+$FFFFFEC0
--- a/test/asm/opt-Q.err
+++ b/test/asm/opt-Q.err
@@ -1,5 +1,3 @@
-warning: opt-Q.asm(10) -> opt-Q.asm::REPT~1(12) -> opt-Q.asm::test(5): [-Wlarge-constant]
- Magnitude of fixed-point constant is too large
error: opt-Q.asm(17) -> opt-Q.asm::test(3):
Argument for option 'Q' must be between 1 and 31
error: opt-Q.asm(18) -> opt-Q.asm::test(3):