This is the mail archive of the gcc@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 Re: sizeof (_Bool)


C and C++ bool should absolutely have the same size.  Does this do the
trick for you?

2002-05-02  Jason Merrill  <jason@redhat.com>

	* defaults.h (BOOL_TYPE_SIZE): Move default here from cp/decl.c.
	* c-decl.c (c_init_decl_processing): Use it.
	* config/rs6000/darwin.h (BOOL_TYPE_SIZE): Define to INT_TYPE_SIZE.
	* config/i960/i960.h (BOOL_TYPE_SIZE): Don't define.
	* config/mcore/mcore.h (BOOL_TYPE_SIZE): Don't define.
	* cp/decl.c (BOOL_TYPE_SIZE): Move default to defaults.h.

*** ./cp/decl.c.~1~	Thu May  2 13:24:12 2002
--- ./cp/decl.c	Thu May  2 12:19:56 2002
*************** Boston, MA 02111-1307, USA.  */
*** 51,61 ****
  
  extern const struct attribute_spec *lang_attribute_table;
  
- #ifndef BOOL_TYPE_SIZE
- /* `bool' has size and alignment `1', on all platforms.  */
- #define BOOL_TYPE_SIZE CHAR_TYPE_SIZE
- #endif
- 
  static tree grokparms				PARAMS ((tree));
  static const char *redeclaration_error_message	PARAMS ((tree, tree));
  
--- 51,56 ----
*** ./c-decl.c.~1~	Thu May  2 13:24:11 2002
--- ./c-decl.c	Thu May  2 12:20:43 2002
*************** c_init_decl_processing ()
*** 3080,3086 ****
    boolean_false_node = integer_zero_node;
  
    /* With GCC, C99's _Bool is always of size 1.  */
!   c_bool_type_node = make_unsigned_type (CHAR_TYPE_SIZE);
    TREE_SET_CODE (c_bool_type_node, BOOLEAN_TYPE);
    TYPE_MAX_VALUE (c_bool_type_node) = build_int_2 (1, 0);
    TREE_TYPE (TYPE_MAX_VALUE (c_bool_type_node)) = c_bool_type_node;
--- 3080,3086 ----
    boolean_false_node = integer_zero_node;
  
    /* With GCC, C99's _Bool is always of size 1.  */
!   c_bool_type_node = make_unsigned_type (BOOL_TYPE_SIZE);
    TREE_SET_CODE (c_bool_type_node, BOOLEAN_TYPE);
    TYPE_MAX_VALUE (c_bool_type_node) = build_int_2 (1, 0);
    TREE_TYPE (TYPE_MAX_VALUE (c_bool_type_node)) = c_bool_type_node;
*** ./config/i960/i960.h.~1~	Thu May  2 14:05:52 2002
--- ./config/i960/i960.h	Thu May  2 14:05:44 2002
*************** struct cum_args { int ca_nregparms; int 
*** 1190,1200 ****
  
  #define SLOW_BYTE_ACCESS 1
  
- /* Force sizeof(bool) == 1 to maintain binary compatibility; otherwise, the
-    change in SLOW_BYTE_ACCESS would have changed it to 4.  */
- 
- #define BOOL_TYPE_SIZE CHAR_TYPE_SIZE
- 
  /* We assume that the store-condition-codes instructions store 0 for false
     and some other value for true.  This is the value stored for true.  */
  
--- 1190,1195 ----
*** ./config/mcore/mcore.h.~1~	Thu May  2 14:03:20 2002
--- ./config/mcore/mcore.h	Thu May  2 14:03:27 2002
*************** extern const char * mcore_stack_incremen
*** 270,278 ****
     words.  */
  #define LONG_LONG_TYPE_SIZE 64
  
- /* the size of the boolean type -- in C++; */
- #define	BOOL_TYPE_SIZE	8
- 
  /* Allocation boundary (in *bits*) for storing arguments in argument list.  */
  #define PARM_BOUNDARY  	32
  
--- 270,275 ----
*** ./config/rs6000/darwin.h.~1~	Thu May  2 14:03:20 2002
--- ./config/rs6000/darwin.h	Thu May  2 14:03:27 2002
*************** Boston, MA 02111-1307, USA.  */
*** 233,235 ****
--- 233,239 ----
     space/speed.  */
  #undef MAX_LONG_TYPE_SIZE
  #define MAX_LONG_TYPE_SIZE 32
+ 
+ /* For binary compatibility with 2.95; Darwin C APIs use bool from
+    stdbool.h, which was an int-sized enum in 2.95.  */
+ #define BOOL_TYPE_SIZE INT_TYPE_SIZE
*** ./doc/tm.texi.~1~	Thu May  2 13:31:39 2002
--- ./doc/tm.texi	Thu May  2 13:03:34 2002
*************** used in @code{cpp}.
*** 1422,1430 ****
  
  @findex BOOL_TYPE_SIZE
  @item BOOL_TYPE_SIZE
! A C expression for the size in bits of the C++ type @code{bool} on the
! target machine.  If you don't define this, the default is
! @code{CHAR_TYPE_SIZE}.
  
  @findex FLOAT_TYPE_SIZE
  @item FLOAT_TYPE_SIZE
--- 1422,1430 ----
  
  @findex BOOL_TYPE_SIZE
  @item BOOL_TYPE_SIZE
! A C expression for the size in bits of the C++ type @code{bool} and
! C99 type @code{_Bool} on the target machine.  If you don't define
! this, and you probably shouldn't, the default is @code{CHAR_TYPE_SIZE}.
  
  @findex FLOAT_TYPE_SIZE
  @item FLOAT_TYPE_SIZE
*** ./defaults.h.~1~	Thu May  2 13:24:11 2002
--- ./defaults.h	Thu May  2 12:19:57 2002
*************** do {								\
*** 285,290 ****
--- 285,295 ----
  #define CHAR_TYPE_SIZE BITS_PER_UNIT
  #endif
  
+ #ifndef BOOL_TYPE_SIZE
+ /* `bool' has size and alignment `1', on all platforms.  */
+ #define BOOL_TYPE_SIZE CHAR_TYPE_SIZE
+ #endif
+ 
  #ifndef SHORT_TYPE_SIZE
  #define SHORT_TYPE_SIZE (BITS_PER_UNIT * MIN ((UNITS_PER_WORD + 1) / 2, 2))
  #endif

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