stdbool: Relax test.
authorBruno Haible <bruno@clisp.org>
Sun, 19 Dec 2010 14:27:30 +0000 (15:27 +0100)
committerBruno Haible <bruno@clisp.org>
Sun, 19 Dec 2010 14:27:30 +0000 (15:27 +0100)
* tests/test-stdbool.c (e): Don't require that casts from a variable's
address to 'bool' work in static initializer, for compilers other than
GCC.

ChangeLog
tests/test-stdbool.c

index 1bea88a5230eeb1e142d4ea70d0b19a2da97e475..204f98c4949b0753ad227c7320d58b6e9b628762 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2010-12-19  Bruno Haible  <bruno@clisp.org>
+
+       stdbool: Relax test.
+       * tests/test-stdbool.c (e): Don't require that casts from a variable's
+       address to 'bool' work in static initializer, for compilers other than
+       GCC.
+
 2010-12-19  Bruno Haible  <bruno@clisp.org>
 
        ftello: Add missing declaration on OSF/1 5.1.
index 2103d8bab99b8655b3a88775fc37e2872767c9e2..bb8d6f36f6aead9fa1c2b59bc4e5bbbfb88413ee 100644 (file)
@@ -61,8 +61,13 @@ char b[false == 0 ? 1 : -1];
 char c[__bool_true_false_are_defined == 1 ? 1 : -1];
 #if HAVE_STDBOOL_H || defined __GNUC__ /* See above.  */
 char d[(bool) 0.5 == true ? 1 : -1];
-# ifdef ADDRESS_CHECK_OKAY
+# ifdef ADDRESS_CHECK_OKAY /* Avoid gcc warning.  */
+/* C99 may plausibly be interpreted as not requiring support for a cast from
+   a variable's address to bool in a static initializer.  So treat it like a
+   GCC extension.  */
+#  ifdef __GNUC__
 bool e = &s;
+#  endif
 # endif
 char f[(_Bool) 0.0 == false ? 1 : -1];
 #endif
@@ -85,6 +90,13 @@ _Bool *pq = &q;
 int
 main ()
 {
+#if HAVE_STDBOOL_H || defined __GNUC__ /* See above.  */
+# ifdef ADDRESS_CHECK_OKAY /* Avoid gcc warning.  */
+  /* A cast from a variable's address to bool is valid in expressions.  */
+  bool e1 = &s;
+# endif
+#endif
+
   /* Catch a bug in IBM AIX xlc compiler version 6.0.0.0
      reported by James Lemley on 2005-10-05; see
      http://lists.gnu.org/archive/html/bug-coreutils/2005-10/msg00086.html