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 1bea88a..204f98c 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
 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.
        * lib/stdio.in.h (ftello): Test HAVE_DECL_FTELLO, not HAVE_FTELLO.
        * m4/ftello.m4 (gl_FUNC_FTELLO): Test whether ftello is declared.
index 2103d8b..bb8d6f3 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