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]

[PATCH] Workaround more _Bool problems on HP-UX


On Thu, 22 Jan 2004, John David Anglin wrote:
> > I had other problems trying to build hppa64 with the native HPUX
> > compiler (patch to follow).
>
> I would like to know about the hppa64 problems that you have
> experienced.

The problem is our old friend the poorly implemented support for
_Bool in HP's native compilers for HPUX.

/usr/bin/cc +DD64 -c   -g -DIN_GCC     -DHAVE_CONFIG_H    -I. -I.
-I../../gcc/gcc -I../../gcc/gcc/. -I../../gcc/gcc/../include -I../intl
../../gcc/gcc/cppfiles.c -o cppfiles.o
cc: line 1327: panic 5172: Backend Assert ** Unimplemented CVT. (5172)

Zack proposed a possible solution to this at the very end of last year,
http://gcc.gnu.org/ml/gcc-patches/2003-12/msg02359.html
but the discussion/review got hung up in the "configure" aspects of his
proposed changes.  Fortunately, for HPUX only his change to system.h is
required to resolve the current failure.  I've changed his original
"#define bool char" to "#define bool unsigned char" to silence the
warnings about signed/unsigned mismatches, and I've also had to make a
few tweaks to GCC's source code where we were defining single bitfields
of type "bool".  Apparently, this is acceptable but their replacement
with either "char foo:1" or "unsigned char foo:1" produces a GCC
extension warning which then breaks bootstrap.  The change below fixes
the small number of occurances of this idiom to explicitly use unsigned
int bitfields.  I hope this is acceptable.

The following patch has been tested on hppa64-hp-hpux11.00 with a full
bootstrap, all languages except Ada and treelang, hosted with the
native hpux compiler using CC="/usr/bin/cc +DD64".  The compilers
now build fine, but I then run into an unrelated(?) failure building
libstdc++-v3; an ICE in rtl_verify_flow_info, at cfgrtl.c:2129.


Ok for mainline?  I'm currently also testing on i686-pc-linux-gnu
just in case.


2004-01-23  Zack Weinberg  <zack@codesourcery.com>
	    Roger Sayle  <roger@eyesopen.com>

	* system.h: Either include <stdbool.h> or simply #define bool,
	true, false; don't muck around with _Bool directly.
	* c-decl.c (struct c_scope): Change parm_flag, function_body,
	keep and warned_forward_parm_decls from bool bit-fields to
	unsigned int bitfields.

	* cp-tree.h (language_function): Change can_throw from a bool
	bit-field to an unsigned int bitfield.
	* name-lookup.h (cp_binding_level): Likewise for explicit_spec_p.


Index: system.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/system.h,v
retrieving revision 1.190
diff -c -3 -p -r1.190 system.h
*** system.h	21 Jan 2004 20:40:04 -0000	1.190
--- system.h	23 Jan 2004 06:42:02 -0000
*************** extern int snprintf (char *, size_t, con
*** 528,537 ****
  #ifdef HAVE_STDBOOL_H
  # include <stdbool.h>
  #else
! # if !HAVE__BOOL
! typedef char _Bool;
! # endif
! # define bool _Bool
  # define true 1
  # define false 0
  #endif
--- 528,534 ----
  #ifdef HAVE_STDBOOL_H
  # include <stdbool.h>
  #else
! # define bool unsigned char
  # define true 1
  # define false 0
  #endif
Index: c-decl.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/c-decl.c,v
retrieving revision 1.472
diff -c -3 -p -r1.472 c-decl.c
*** c-decl.c	21 Jan 2004 10:32:05 -0000	1.472
--- c-decl.c	23 Jan 2004 06:42:03 -0000
*************** struct c_scope GTY(())
*** 230,250 ****

    /* True if we are currently filling this scope with parameter
       declarations.  */
!   bool parm_flag : 1;

    /* True if we already complained about forward parameter decls
       in this scope.  This prevents double warnings on
       foo (int a; int b; ...)  */
!   bool warned_forward_parm_decls : 1;

    /* True if this is the outermost block scope of a function body.
       This scope contains the parameters, the local variables declared
       in the outermost block, and all the labels (except those in
       nested functions, or declared at block scope with __label__).  */
!   bool function_body : 1;

    /* True means make a BLOCK for this scope no matter what.  */
!   bool keep : 1;
  };

  /* The scope currently in effect.  */
--- 230,250 ----

    /* True if we are currently filling this scope with parameter
       declarations.  */
!   unsigned int parm_flag : 1;

    /* True if we already complained about forward parameter decls
       in this scope.  This prevents double warnings on
       foo (int a; int b; ...)  */
!   unsigned int warned_forward_parm_decls : 1;

    /* True if this is the outermost block scope of a function body.
       This scope contains the parameters, the local variables declared
       in the outermost block, and all the labels (except those in
       nested functions, or declared at block scope with __label__).  */
!   unsigned int function_body : 1;

    /* True means make a BLOCK for this scope no matter what.  */
!   unsigned int keep : 1;
  };

  /* The scope currently in effect.  */
Index: cp/cp-tree.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/cp-tree.h,v
retrieving revision 1.947
diff -c -3 -p -r1.947 cp-tree.h
*** cp/cp-tree.h	19 Jan 2004 20:33:20 -0000	1.947
--- cp/cp-tree.h	23 Jan 2004 06:42:04 -0000
*************** struct language_function GTY(())
*** 794,800 ****
    int in_base_initializer;

    /* True if this function can throw an exception.  */
!   bool can_throw : 1;

    struct named_label_use_list *x_named_label_uses;
    struct named_label_list *x_named_labels;
--- 794,800 ----
    int in_base_initializer;

    /* True if this function can throw an exception.  */
!   unsigned int can_throw : 1;

    struct named_label_use_list *x_named_label_uses;
    struct named_label_list *x_named_labels;
Index: cp/name-lookup.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/name-lookup.h,v
retrieving revision 1.15
diff -c -3 -p -r1.15 name-lookup.h
*** cp/name-lookup.h	15 Jan 2004 14:49:56 -0000	1.15
--- cp/name-lookup.h	23 Jan 2004 06:42:04 -0000
*************** struct cp_binding_level GTY(())
*** 215,221 ****

      /* True if this scope is an SK_TEMPLATE_SPEC scope.  This field is
         only valid if KIND == SK_TEMPLATE_PARMS.  */
!     bool explicit_spec_p : 1;

      /* true means make a BLOCK for this level regardless of all else.  */
      unsigned keep : 1;
--- 215,221 ----

      /* True if this scope is an SK_TEMPLATE_SPEC scope.  This field is
         only valid if KIND == SK_TEMPLATE_PARMS.  */
!     unsigned int explicit_spec_p : 1;

      /* true means make a BLOCK for this level regardless of all else.  */
      unsigned keep : 1;

Roger
--
Roger Sayle,                         E-mail: roger@eyesopen.com
OpenEye Scientific Software,         WWW: http://www.eyesopen.com/
Suite 1107, 3600 Cerrillos Road,     Tel: (+1) 505-473-7385
Santa Fe, New Mexico, 87507.         Fax: (+1) 505-473-0833


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