This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Minor work-around for native HPPA compiler bug


Roger Sayle <roger@eyesopen.com> writes:

> A failing test case, perhaps suitable for an autoconf test, is:
>
> void foo(_Bool *ptr, _Bool val)
> {
>   *ptr |= ! val;
> }

Thanks.  Could you please try the appended patch?  You'll need to
run both autoconf and autoheader after applying it.  (Configure should
print "checking for bool and stdbool.h... buggy" with the problem
compiler.)

zw

        * aclocal.m4 (gcc_AC_HEADER_STDBOOL): Fold into ...
        (gcc_AC_C__BOOL): ... here; rename gcc_AC_C_BOOL_STDBOOL_H;
        add check for HP-UX compiler bug.
        * configure.in: Update to match.
        * system.h: Update to match.  Either include <stdbool.h> or
        simply #define bool, true, false; don't muck around with _Bool
        directly.

===================================================================
Index: aclocal.m4
--- aclocal.m4	7 Dec 2003 16:12:25 -0000	1.86
+++ aclocal.m4	31 Dec 2003 22:27:46 -0000
@@ -3,19 +3,6 @@ sinclude(../config/accross.m4)
 sinclude(../config/gettext.m4)
 sinclude(../config/progtest.m4)
 
-dnl See if stdbool.h properly defines bool and true/false.
-AC_DEFUN([gcc_AC_HEADER_STDBOOL],
-[AC_CACHE_CHECK([for working stdbool.h],
-  ac_cv_header_stdbool_h,
-[AC_TRY_COMPILE([#include <stdbool.h>],
-[bool foo = false;],
-ac_cv_header_stdbool_h=yes, ac_cv_header_stdbool_h=no)])
-if test $ac_cv_header_stdbool_h = yes; then
-  AC_DEFINE(HAVE_STDBOOL_H, 1,
-  [Define if you have a working <stdbool.h> header file.])
-fi
-])
-
 dnl Fixed AC_CHECK_TYPE that doesn't need anything in acconfig.h.
 dnl Remove after migrating to 2.5x.
 AC_DEFUN([gcc_AC_CHECK_TYPE],
@@ -220,14 +207,25 @@ AC_SUBST(LN)dnl
 ])
 
 dnl Check whether _Bool is built-in.
-AC_DEFUN([gcc_AC_C__BOOL],
-[AC_CACHE_CHECK(for built-in _Bool, gcc_cv_c__bool,
-[AC_TRY_COMPILE(,
-[_Bool foo;],
-gcc_cv_c__bool=yes, gcc_cv_c__bool=no)
-])
-if test $gcc_cv_c__bool = yes; then
-  AC_DEFINE(HAVE__BOOL, 1, [Define if the \`_Bool' type is built-in.])
+AC_DEFUN([gcc_AC_C_BOOL_STDBOOL_H],
+[AC_CACHE_CHECK([for bool and stdbool.h], gcc_cv_c_bool_stdbool_h,
+[AC_TRY_COMPILE([#include <stdbool.h>
+],
+[bool foo = false;],
+[# Now test for bugs in _Bool support.
+# This construct provokes an ICE in HP's C compiler (reported Dec 2003).
+AC_TRY_COMPILE([#include <stdbool.h>
+],
+[void foo(bool *ptr, bool val)
+{
+  *ptr |= ! val;
+}],
+gcc_cv_c_bool_stdbool_h=yes, 
+gcc_cv_c_bool_stdbool_h=buggy)],
+gcc_cv_c_bool_stdbool_h=no)])
+if test $gcc_cv_c_bool_stdbool_h = yes; then
+  AC_DEFINE(HAVE_BOOL_AND_STDBOOL_H, 1, 
+    [Define if you have a working bool and \`stdbool.h\'])
 fi
 ])
 
===================================================================
Index: configure.in
--- configure.in	22 Dec 2003 07:42:37 -0000	1.763
+++ configure.in	31 Dec 2003 22:27:47 -0000
@@ -263,7 +263,7 @@ AC_PROG_CPP
 AC_C_INLINE
 
 gcc_AC_C_LONG_LONG
-gcc_AC_C__BOOL
+gcc_AC_C_BOOL_STDBOOL_H
 
 # sizeof(char) is 1 by definition.
 AC_COMPILE_CHECK_SIZEOF(void *)
@@ -684,7 +684,6 @@ fi
 
 AC_HEADER_STDC
 AC_HEADER_TIME
-gcc_AC_HEADER_STDBOOL
 gcc_AC_HEADER_STRING
 AC_HEADER_SYS_WAIT
 AC_CHECK_HEADERS(limits.h stddef.h string.h strings.h stdlib.h time.h \
===================================================================
Index: system.h
--- system.h	22 Dec 2003 05:52:50 -0000	1.179
+++ system.h	31 Dec 2003 22:27:47 -0000
@@ -371,9 +371,9 @@ extern int snprintf (char *, size_t, con
   ((GCC_VERSION >= 2007) || (__STDC_VERSION__ >= 199901L))
 #endif
 
-/* 1 if we have _Bool.  */
-#ifndef HAVE__BOOL
-# define HAVE__BOOL \
+/* 1 if we have a correct implementation of both _Bool and stdbool.h.  */
+#ifndef HAVE_BOOL_AND_STDBOOL_H
+# define HAVE_BOOL_AND_STDBOOL_H \
    ((GCC_VERSION >= 3000) || (__STDC_VERSION__ >= 199901L))
 #endif
 
@@ -524,13 +524,10 @@ extern int snprintf (char *, size_t, con
 #undef TRUE
 #undef FALSE
 
-#ifdef HAVE_STDBOOL_H
+#if HAVE_BOOL_AND_STDBOOL_H
 # include <stdbool.h>
 #else
-# if !HAVE__BOOL
-typedef char _Bool;
-# endif
-# define bool _Bool
+# define bool char
 # define true 1
 # define false 0
 #endif


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]