summaryrefslogtreecommitdiff
path: root/support
diff options
context:
space:
mode:
authorspth <spth@4a8a32a2-be11-0410-ad9d-d568d2c75423>2025-08-07 19:28:52 +0000
committerspth <spth@4a8a32a2-be11-0410-ad9d-d568d2c75423>2025-08-07 19:28:52 +0000
commit74a419dc11921978d768e4596f2a3bab6916a67d (patch)
tree73eaf7f80254b0d2bd6d0c9b142b5b19e8fd40fd /support
parentcf2b70e27de198c2665aec23526ca7cf1fb4831e (diff)
Partially fix bug #3719.HEADgit-svn/mastergit-svn/HEADmaster
git-svn-id: http://svn.code.sourceforge.net/p/sdcc/code/trunk/sdcc@15561 4a8a32a2-be11-0410-ad9d-d568d2c75423
Diffstat (limited to 'support')
-rw-r--r--support/regression/tests/bitintfromfloat.c.in39
-rw-r--r--support/regression/tests/bitinttofloat.c.in (renamed from support/regression/tests/bitintfloat.c.in)5
2 files changed, 39 insertions, 5 deletions
diff --git a/support/regression/tests/bitintfromfloat.c.in b/support/regression/tests/bitintfromfloat.c.in
new file mode 100644
index 000000000..fc687db5d
--- /dev/null
+++ b/support/regression/tests/bitintfromfloat.c.in
@@ -0,0 +1,39 @@
+/** casts between bit-precise integers and float
+
+ width: 2, 4, 6, 7, 8, 9, 15, 16, 17, 24, 32, 33, 40, 48, 63, 64, 65
+ sign: unsigned, signed
+*/
+
+#include <testfwk.h>
+
+#include <float.h>
+
+// clang 11 supports bit-precise types, but deviates a bit from C23.
+#if __clang_major__ == 11
+#define __SDCC_BITINT_MAXWIDTH 128
+#define _BitInt _ExtInt
+#endif
+
+// Remaining part of bug: does not compile for width > 32.
+#if __SDCC_BITINT_MAXWIDTH >= {width} && 32 >= {width} // TODO: When we can regression-test in --std-c23 mode, use the standard macro from limits.h instead!
+
+typedef {sign} _BitInt({width}) bitinttype;
+
+bitinttype from_float(float f)
+{
+ return(f);
+}
+#endif
+
+void testCast (void)
+{
+#if __SDCC_BITINT_MAXWIDTH >= {width} && 32 >= {width} // TODO: When we can regression-test in --std-c23 mode, use the standard macro from limits.h instead!
+ float f;
+
+ f = 1;
+#if !defined(__SDCC_pdk14) && !defined(__SDCC_pdk15) // Reming part of bug: fails for pdk14, pdk15.
+ ASSERT (from_float (f) == (bitinttype)f);
+#endif
+#endif
+}
+
diff --git a/support/regression/tests/bitintfloat.c.in b/support/regression/tests/bitinttofloat.c.in
index 77d5ae986..1645c5b3f 100644
--- a/support/regression/tests/bitintfloat.c.in
+++ b/support/regression/tests/bitinttofloat.c.in
@@ -22,11 +22,6 @@ float to_float(bitinttype b)
{
return(b);
}
-
-/*bitinttype from_float(float f)
-{
- return(f);
-}*/
#endif
void testCast (void)