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
+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
#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
#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
}
#include <testfwk.h>
#include <stdbool.h>
+#ifdef __bool_true_false_are_defined
+
union USUINT {
unsigned int value;
struct {
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
}
-/* 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
#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
}
void
testFoo1(void)
{
+#ifdef __bool_true_false_are_defined
+
#if defined(PORT_HOST)
volatile bool sb, ub;
#else
ASSERT (! (-1 >= INT_CAST ub));
ASSERT ( ( 0 >= ub));
+#endif //__bool_true_false_are_defined
}
void