From: MaartenBrock Date: Tue, 10 Jul 2007 12:12:48 +0000 (+0000) Subject: * device/include/stdbool.h: do not define __bool_true_false_are_defined X-Git-Url: https://git.gag.com/?a=commitdiff_plain;h=6a196df8ed13a6b364f4e4bbdcb8361125b0ea4f;hp=a447f8806f692f0e6c172ddd47b8b290019fdd62;p=fw%2Fsdcc * 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 git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@4877 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- diff --git a/ChangeLog b/ChangeLog index 71936861..34dd3781 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2007-07-10 Maarten Brock + + * 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 * src/mcs51/peep.c (isCallerSaveFunc): fixed bug 1749275, thanks Robert diff --git a/device/include/stdbool.h b/device/include/stdbool.h index 02f41cf6..1144be10 100644 --- a/device/include/stdbool.h +++ b/device/include/stdbool.h @@ -21,17 +21,20 @@ #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 diff --git a/support/regression/tests/bug1546986.c b/support/regression/tests/bug1546986.c index b22b67f8..5e120a35 100644 --- a/support/regression/tests/bug1546986.c +++ b/support/regression/tests/bug1546986.c @@ -5,16 +5,22 @@ #include #include +#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 } diff --git a/support/regression/tests/bug1723128.c b/support/regression/tests/bug1723128.c index e140e39b..e147836d 100644 --- a/support/regression/tests/bug1723128.c +++ b/support/regression/tests/bug1723128.c @@ -5,6 +5,8 @@ #include #include +#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 } diff --git a/support/regression/tests/bug1734654.c b/support/regression/tests/bug1734654.c index 4983bad0..8eecc153 100644 --- a/support/regression/tests/bug1734654.c +++ b/support/regression/tests/bug1734654.c @@ -1,19 +1,25 @@ -/* bug1734654.c - */ -#include -#include - -volatile bool b; -volatile unsigned char c = 1; - -static void foo (void) -{ - b = (c<2); -} - -void -testMyFunc(void) -{ - foo (); - ASSERT (b); -} +/* bug1734654.c + */ +#include +#include + +#ifdef __bool_true_false_are_defined + +volatile bool b; +volatile unsigned char c = 1; + +static void foo (void) +{ + b = (c<2); +} + +#endif //__bool_true_false_are_defined + +void +testMyFunc(void) +{ +#ifdef __bool_true_false_are_defined + foo (); + ASSERT (b); +#endif //__bool_true_false_are_defined +} diff --git a/support/regression/tests/bug1738367.c b/support/regression/tests/bug1738367.c index a96297af..f9da20e0 100644 --- a/support/regression/tests/bug1738367.c +++ b/support/regression/tests/bug1738367.c @@ -5,14 +5,21 @@ #include #include -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 } diff --git a/support/regression/tests/constantRange.c b/support/regression/tests/constantRange.c index 1dfc10cf..3b0d283c 100644 --- a/support/regression/tests/constantRange.c +++ b/support/regression/tests/constantRange.c @@ -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