public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jason Merrill <jason@redhat.com>
To: Stan Shebs <shebs@apple.com>
Cc: <gcc@gcc.gnu.org>,
	gcc-patches@gcc.gnu.org, "Joseph S. Myers" <jsm28@cam.ac.uk>,
Subject: PATCH Re: sizeof (_Bool)
Date: Thu, 02 May 2002 06:15:00 -0000	[thread overview]
Message-ID: <wvl8z72bsii.fsf_-_@prospero.cambridge.redhat.com> (raw)
In-Reply-To: <Pine.LNX.4.33.0204270057480.12099-100000@kern.srcf.societies.cam.ac.uk> ("Joseph S. Myers"'s message of "Sat, 27 Apr 2002 01:02:15 +0100 (BST)")

[-- Attachment #1: Type: text/plain, Size: 485 bytes --]

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.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: Type: text/x-patch, Size: 3999 bytes --]

*** ./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

  reply	other threads:[~2002-05-02 13:15 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-04-26 15:52 Stan Shebs
2002-04-26 16:29 ` Joseph S. Myers
2002-04-26 16:49   ` Stan Shebs
2002-04-26 17:53     ` Joseph S. Myers
2002-05-02  6:15       ` Jason Merrill [this message]
2002-05-02  8:27         ` PATCH " Stan Shebs
2002-04-26 16:30 ` mike stump
2002-04-29 22:42 ` Aldy Hernandez
2002-04-30 10:29   ` Dale Johannesen
2002-04-30 17:44     ` Aldy Hernandez
2002-05-02  5:43       ` Jason Merrill

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=wvl8z72bsii.fsf_-_@prospero.cambridge.redhat.com \
    --to=jason@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=gcc@gcc.gnu.org \
    --cc=jsm28@cam.ac.uk \
    --cc=shebs@apple.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).