* device/include/stdbool.h: do not define __bool_true_false_are_defined
authorMaartenBrock <MaartenBrock@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Tue, 10 Jul 2007 12:12:48 +0000 (12:12 +0000)
committerMaartenBrock <MaartenBrock@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Tue, 10 Jul 2007 12:12:48 +0000 (12:12 +0000)
  and bool for targets that do not fully support it.
* support/regression/tests/bug1546986.c,
* support/regression/tests/bug1723128.c,
* support/regression/tests/bug1734654.c,
* support/regression/tests/bug1738367.c,
* support/regression/tests/constantRange.c: only use bool if allowed

git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@4877 4a8a32a2-be11-0410-ad9d-d568d2c75423

ChangeLog
device/include/stdbool.h
support/regression/tests/bug1546986.c
support/regression/tests/bug1723128.c
support/regression/tests/bug1734654.c
support/regression/tests/bug1738367.c
support/regression/tests/constantRange.c

index 71936861dca0d25aa098c2a357c94a6dcc7e3976..34dd3781dcb1b40634de4de2de45a0373199af26 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2007-07-10 Maarten Brock <sourceforge.brock AT dse.nl>
+
+       * device/include/stdbool.h: do not define __bool_true_false_are_defined
+         and bool for targets that do not fully support it.
+       * support/regression/tests/bug1546986.c,
+       * support/regression/tests/bug1723128.c,
+       * support/regression/tests/bug1734654.c,
+       * support/regression/tests/bug1738367.c,
+       * support/regression/tests/constantRange.c: only use bool if allowed
+
 2007-07-09 Maarten Brock <sourceforge.brock AT dse.nl>
 
        * src/mcs51/peep.c (isCallerSaveFunc): fixed bug 1749275, thanks Robert
index 02f41cf60ad234300e14172e991fa63515be0434..1144be10056f56d4f7883e12d30372bd86d996a9 100644 (file)
 #ifndef __SDC51_STDBOOL_H
 #define __SDC51_STDBOOL_H 1
 
-#define _Bool BOOL
-
-#define bool BOOL
 #define true 1
 #define false 0
-#define __bool_true_false_are_defined 1
+
+// Only define bool for ports that really support it to the full extend.
+// For other ports only define BOOL which can be used in most cases,
+// but can result in unexpected behaviour
 
 #if defined (SDCC_hc08) || defined (SDCC_z80) || defined (SDCC_gbz80) || defined (SDCC_pic14) || defined (SDCC_pic16)
  #define BOOL char
 #else
- #define BOOL __bit
+ #define _Bool __bit
+ #define BOOL  __bit
+ #define bool  _Bool
+ #define __bool_true_false_are_defined 1
 #endif
 
 #endif
index b22b67f8fe93119a8274baead99309ef37fa57b1..5e120a3562f0fd489dc00eaff96096b76f40e91f 100644 (file)
@@ -5,16 +5,22 @@
 #include <testfwk.h>
 #include <stdbool.h>
 
+#ifdef __bool_true_false_are_defined
+
 static unsigned char pdata tst1 = 0x01;
 static unsigned char pdata tst2 = 0x00;
 
 static bool test;
 
+#endif //__bool_true_false_are_defined
+
 void
 testBug(void)
 {
+#ifdef __bool_true_false_are_defined
   test = (tst1 | tst2);
   ASSERT( test );
   test = (tst2 | tst1);
   ASSERT( test );
+#endif //__bool_true_false_are_defined
 }
index e140e39b681dfddbe5719ce341fb81c7375b7be2..e147836d5cfd2aed357b1cd0a53a0f6144a6d2ea 100644 (file)
@@ -5,6 +5,8 @@
 #include <testfwk.h>
 #include <stdbool.h>
 
+#ifdef __bool_true_false_are_defined
+
 union USUINT {
     unsigned int value;
     struct {
@@ -80,10 +82,14 @@ bool NotZero(unsigned int t)
     return (t != 0);
 }
 
+#endif //__bool_true_false_are_defined
+
 void
 testBug(void)
 {
+#ifdef __bool_true_false_are_defined
     rx_index = 1;
     ASSERT (VerifyCRC());
     ASSERT (NotZero(300));
+#endif //__bool_true_false_are_defined
 }
index 4983bad09fdd8e7681a614f3f704423c8b5724cc..8eecc153b77f84f120c27423e432a7c0784cd46c 100644 (file)
@@ -1,19 +1,25 @@
-/* bug1734654.c
- */
-#include <testfwk.h>
-#include <stdbool.h>
-
-volatile bool b;
-volatile unsigned char c = 1;
-
-static void foo (void)
-{
-  b = (c<2);
-}
-
-void
-testMyFunc(void)
-{
-  foo ();
-  ASSERT (b);
-}
+/* bug1734654.c\r
+ */\r
+#include <testfwk.h>\r
+#include <stdbool.h>\r
+\r
+#ifdef __bool_true_false_are_defined\r
+\r
+volatile bool b;\r
+volatile unsigned char c = 1;\r
+\r
+static void foo (void)\r
+{\r
+  b = (c<2);\r
+}\r
+\r
+#endif //__bool_true_false_are_defined\r
+\r
+void\r
+testMyFunc(void)\r
+{\r
+#ifdef __bool_true_false_are_defined\r
+  foo ();\r
+  ASSERT (b);\r
+#endif //__bool_true_false_are_defined\r
+}\r
index a96297afebf9f07fabb0481ba5b112baaf9dfda4..f9da20e075549816b1a45325b418d7bde871236e 100644 (file)
@@ -5,14 +5,21 @@
 #include <testfwk.h>
 #include <stdbool.h>
 
-bool Ternary(unsigned char status)
+#ifdef __bool_true_false_are_defined
+
+bool ternary(unsigned char status)
 {
        return (status == 0) ? 0 : 1;
 }
 
+#endif //__bool_true_false_are_defined
+
+
 void
 testBug(void)
 {
-       ASSERT(!Ternary(0x00));
-       ASSERT( Ternary(0x10));
+#ifdef __bool_true_false_are_defined
+       ASSERT(!ternary(0x00));
+       ASSERT( ternary(0x10));
+#endif //__bool_true_false_are_defined
 }
index 1dfc10cfdbc63a490a7f5426bdc06468e8c7cda6..3b0d283cda3f632182a0a4169ba3c599388fd44f 100644 (file)
@@ -122,6 +122,8 @@ testConstantRange (void)
 void
 testFoo1(void)
 {
+#ifdef __bool_true_false_are_defined
+
 #if defined(PORT_HOST)
    volatile bool sb, ub;
 #else
@@ -172,6 +174,7 @@ testFoo1(void)
 
   ASSERT (! (-1 >= INT_CAST ub));
   ASSERT (  ( 0 >= ub));
+#endif //__bool_true_false_are_defined
 }
 
 void