summaryrefslogtreecommitdiff
path: root/support/regression/tests/bug1738367.c
diff options
context:
space:
mode:
authorXavier ASUS <xavi92psx@gmail.com>2019-10-18 00:31:54 +0200
committerXavier ASUS <xavi92psx@gmail.com>2019-10-18 00:31:54 +0200
commit268a53de823a6750d6256ee1fb1e7707b4b45740 (patch)
tree42c1799a9a82b2f7d9790ee9fe181d72a7274751 /support/regression/tests/bug1738367.c
downloadsdcc-gas-268a53de823a6750d6256ee1fb1e7707b4b45740.tar.gz
sdcc-3.9.0 fork implementing GNU assembler syntax
This fork aims to provide better support for stm8-binutils
Diffstat (limited to 'support/regression/tests/bug1738367.c')
-rw-r--r--support/regression/tests/bug1738367.c75
1 files changed, 75 insertions, 0 deletions
diff --git a/support/regression/tests/bug1738367.c b/support/regression/tests/bug1738367.c
new file mode 100644
index 0000000..e0fcb0f
--- /dev/null
+++ b/support/regression/tests/bug1738367.c
@@ -0,0 +1,75 @@
+/*
+ bug1738367.c
+*/
+
+#include <testfwk.h>
+
+#ifdef __SDCC
+#pragma std_sdcc99
+#endif
+
+#include <stdbool.h>
+
+#ifdef __bool_true_false_are_defined
+
+bool ternary(unsigned char status)
+{
+ return (status == 0) ? 0 : 1;
+}
+
+bool ternary_inv(unsigned char status)
+{
+ return (status == 0) ? 1 : 0;
+}
+
+
+bool ternary1(unsigned char status)
+{
+ return status ? 1 : 0;
+}
+
+bool ternary1_inv(unsigned char status)
+{
+ return status ? 0 : 1;
+}
+
+
+bool ternary2(unsigned char status)
+{
+ return !status ? 0 : 1;
+}
+
+bool ternary2_inv(unsigned char status)
+{
+ return !status ? 1 : 0;
+}
+
+#endif //__bool_true_false_are_defined
+
+
+void
+testBug(void)
+{
+#ifndef __SDCC_pic16
+#ifdef __bool_true_false_are_defined
+ ASSERT(!ternary(0x00));
+ ASSERT( ternary(0x10));
+
+ ASSERT( ternary_inv(0x00));
+ ASSERT(!ternary_inv(0x10));
+
+ ASSERT(!ternary1(0x00));
+ ASSERT( ternary1(0x10));
+
+ ASSERT( ternary1_inv(0x00));
+ ASSERT(!ternary1_inv(0x10));
+
+ ASSERT(!ternary2(0x00));
+ ASSERT( ternary2(0x10));
+
+ ASSERT( ternary2_inv(0x00));
+ ASSERT(!ternary2_inv(0x10));
+ ASSERT(!ternary2_inv(1==1));
+#endif //__bool_true_false_are_defined
+#endif
+}