full 16 bit addressing support for 16 bit targets

Joern Rennecke amylaar@cygnus.co.uk
Tue Sep 30 12:47:00 GMT 1997


When compiling the following function for the h8300 target:

int f()
{
  int a[4097];

  a[0] = 0;
  a[4096] = 1;
  return a[0];
}

cc1 complains with an error 'size of array `a' is too large' and emits
incorrect code.  This happens because size_t is just 16 bit wide, and
gcc truncates bit sizes and offsets within arrays to size_t.

Here is a fix:

Tue Sep 30 19:56:37 1997  J"orn Rennecke <amylaar@cygnus.co.uk>

	* c-decl.c (init_decl_processing): Use bitsizetype for type sizes.
	* expr.c (get_inner_reference): Use sbitsizetype for type sizes.
	* fold-const.c (size_int): Replace with
	(size_int_wide).
	(make_bit_field_ref): Use bitsize_int for bit position.
	* stor-layout.c (sizetype): Delete.
	(sizetype_tab, sbitsizetype, ubitsizetype): Declare.
	(layout_union, layout_type): Use bitsize_int for bit size.
	(make_signed_type, make_unsigned_type): Initialize *bitsizetype.
	* tree.h (size_int): Don't delcare, #define.
	(size_int_wide, sizetype_tab, sbitsize, ubitsize): Declare.
	(bitsize_int, size_int_2, BITS_PER_UNIT_LOG, sizetype, bitsizetype):
	Define.
	* c-typeck.c (c_sizeof, c_sizeof_nowarn, c_size_in_bytes):
	Convert result to sizetype.

Tue Sep 30 19:57:59 1997  J"orn Rennecke <amylaar@cygnus.co.uk>

	* cp/decl.c (init_decl_processing): Use bitsizetype for type sizes.
	* cp/decl2.c (sizetype): Don't declare.
	* cp/typeck.c (c_sizeof, c_sizeof_nowarn): Convert result to sizetype.

diff -p ../ss-970926/c-decl.c ./c-decl.c
*** ../ss-970926/c-decl.c	Mon Sep 29 19:33:15 1997
--- ./c-decl.c	Tue Sep 30 16:41:24 1997
*************** init_decl_processing ()
*** 2908,2931 ****
    /* `unsigned long' is the standard type for sizeof.
       Traditionally, use a signed type.
       Note that stddef.h uses `unsigned long',
!      and this must agree, even of long and int are the same size.  */
    sizetype
      = TREE_TYPE (IDENTIFIER_GLOBAL_VALUE (get_identifier (SIZE_TYPE)));
    if (flag_traditional && TREE_UNSIGNED (sizetype))
!     sizetype = signed_type (sizetype);
  
    ptrdiff_type_node
      = TREE_TYPE (IDENTIFIER_GLOBAL_VALUE (get_identifier (PTRDIFF_TYPE)));
  
!   TREE_TYPE (TYPE_SIZE (integer_type_node)) = sizetype;
!   TREE_TYPE (TYPE_SIZE (char_type_node)) = sizetype;
!   TREE_TYPE (TYPE_SIZE (unsigned_type_node)) = sizetype;
!   TREE_TYPE (TYPE_SIZE (long_unsigned_type_node)) = sizetype;
!   TREE_TYPE (TYPE_SIZE (long_integer_type_node)) = sizetype;
!   TREE_TYPE (TYPE_SIZE (long_long_integer_type_node)) = sizetype;
!   TREE_TYPE (TYPE_SIZE (long_long_unsigned_type_node)) = sizetype;
!   TREE_TYPE (TYPE_SIZE (short_integer_type_node)) = sizetype;
!   TREE_TYPE (TYPE_SIZE (short_unsigned_type_node)) = sizetype;
  
    error_mark_node = make_node (ERROR_MARK);
    TREE_TYPE (error_mark_node) = error_mark_node;
--- 2908,2934 ----
    /* `unsigned long' is the standard type for sizeof.
       Traditionally, use a signed type.
       Note that stddef.h uses `unsigned long',
!      and this must agree, even if long and int are the same size.  */
    sizetype
      = TREE_TYPE (IDENTIFIER_GLOBAL_VALUE (get_identifier (SIZE_TYPE)));
    if (flag_traditional && TREE_UNSIGNED (sizetype))
!     {
!       sizetype = signed_type (sizetype);
!       bitsizetype = sbitsizetype;
!     }
  
    ptrdiff_type_node
      = TREE_TYPE (IDENTIFIER_GLOBAL_VALUE (get_identifier (PTRDIFF_TYPE)));
  
!   TREE_TYPE (TYPE_SIZE (integer_type_node)) = bitsizetype;
!   TREE_TYPE (TYPE_SIZE (char_type_node)) = bitsizetype;
!   TREE_TYPE (TYPE_SIZE (unsigned_type_node)) = bitsizetype;
!   TREE_TYPE (TYPE_SIZE (long_unsigned_type_node)) = bitsizetype;
!   TREE_TYPE (TYPE_SIZE (long_integer_type_node)) = bitsizetype;
!   TREE_TYPE (TYPE_SIZE (long_long_integer_type_node)) = bitsizetype;
!   TREE_TYPE (TYPE_SIZE (long_long_unsigned_type_node)) = bitsizetype;
!   TREE_TYPE (TYPE_SIZE (short_integer_type_node)) = bitsizetype;
!   TREE_TYPE (TYPE_SIZE (short_unsigned_type_node)) = bitsizetype;
  
    error_mark_node = make_node (ERROR_MARK);
    TREE_TYPE (error_mark_node) = error_mark_node;
diff -p ../ss-970926/expr.c ./expr.c
*** ../ss-970926/expr.c	Mon Sep 29 18:12:19 1997
--- ./expr.c	Tue Sep 30 18:13:38 1997
*************** get_inner_reference (exp, pbitsize, pbit
*** 4385,4399 ****
  	  if (! integer_zerop (low_bound))
  	    index = fold (build (MINUS_EXPR, index_type, index, low_bound));
  
! 	  if (TYPE_PRECISION (index_type) != TYPE_PRECISION (sizetype))
  	    {
  	      index = convert (type_for_size (TYPE_PRECISION (sizetype), 0),
  			       index);
  	      index_type = TREE_TYPE (index);
  	    }
  
! 	  index = fold (build (MULT_EXPR, index_type, index,
! 			       convert (index_type,
  					TYPE_SIZE (TREE_TYPE (exp)))));
  
  	  if (TREE_CODE (index) == INTEGER_CST
--- 4385,4404 ----
  	  if (! integer_zerop (low_bound))
  	    index = fold (build (MINUS_EXPR, index_type, index, low_bound));
  
! 	  if (TREE_CODE (index) == INTEGER_CST)
! 	    {
! 	      index = convert (sbitsizetype, index);
! 	      index_type = TREE_TYPE (index);
! 	    }
! 	  else if (TYPE_PRECISION (index_type) != TYPE_PRECISION (sizetype))
  	    {
  	      index = convert (type_for_size (TYPE_PRECISION (sizetype), 0),
  			       index);
  	      index_type = TREE_TYPE (index);
  	    }
  
! 	  index = fold (build (MULT_EXPR, sbitsizetype, index,
! 			       convert (sbitsizetype,
  					TYPE_SIZE (TREE_TYPE (exp)))));
  
  	  if (TREE_CODE (index) == INTEGER_CST
diff -p ../ss-970926/fold-const.c ./fold-const.c
*** ../ss-970926/fold-const.c	Mon Sep 29 18:12:20 1997
--- ./fold-const.c	Mon Sep 29 21:13:58 1997
*************** Boston, MA 02111-1307, USA.  */
*** 27,33 ****
    @@ for cross-compilers.  */
  
  
! /* The entry points in this file are fold, size_int, size_binop
     and force_fit_type.
  
     fold takes a tree as argument and returns a simplified tree.
--- 27,33 ----
    @@ for cross-compilers.  */
  
  
! /* The entry points in this file are fold, size_int_wide, size_binop
     and force_fit_type.
  
     fold takes a tree as argument and returns a simplified tree.
*************** const_binop (code, arg1, arg2, notrunc)
*** 1419,1451 ****
    return 0;
  }
  
! /* Return an INTEGER_CST with value V and type from `sizetype'.  */
  
  tree
! size_int (number)
!      unsigned HOST_WIDE_INT number;
  {
    register tree t;
    /* Type-size nodes already made for small sizes.  */
!   static tree size_table[2*HOST_BITS_PER_WIDE_INT + 1];
  
!   if (number < 2*HOST_BITS_PER_WIDE_INT + 1
!       && size_table[number] != 0)
!     return size_table[number];
!   if (number < 2*HOST_BITS_PER_WIDE_INT + 1)
      {
        push_obstacks_nochange ();
        /* Make this a permanent node.  */
        end_temporary_allocation ();
        t = build_int_2 (number, 0);
!       TREE_TYPE (t) = sizetype;
!       size_table[number] = t;
        pop_obstacks ();
      }
    else
      {
!       t = build_int_2 (number, 0);
!       TREE_TYPE (t) = sizetype;
        TREE_OVERFLOW (t) = TREE_CONSTANT_OVERFLOW (t) = force_fit_type (t, 0);
      }
    return t;
--- 1419,1453 ----
    return 0;
  }
  
! /* Return an INTEGER_CST with value V .  The type is determined by bit_p:
!    if it is zero, the type is taken from sizetype; if it is one, the type
!    is taken from bitsizetype.  */
  
  tree
! size_int_wide (number, high, bit_p)
!      unsigned HOST_WIDE_INT number, high;
  {
    register tree t;
    /* Type-size nodes already made for small sizes.  */
!   static tree size_table[2*HOST_BITS_PER_WIDE_INT + 1][2];
  
!   if (number < 2*HOST_BITS_PER_WIDE_INT + 1 && ! high
!       && size_table[number][bit_p] != 0)
!     return size_table[number][bit_p];
!   if (number < 2*HOST_BITS_PER_WIDE_INT + 1 && ! high)
      {
        push_obstacks_nochange ();
        /* Make this a permanent node.  */
        end_temporary_allocation ();
        t = build_int_2 (number, 0);
!       TREE_TYPE (t) = sizetype_tab[bit_p];
!       size_table[number][bit_p] = t;
        pop_obstacks ();
      }
    else
      {
!       t = build_int_2 (number, high);
!       TREE_TYPE (t) = sizetype_tab[bit_p];
        TREE_OVERFLOW (t) = TREE_CONSTANT_OVERFLOW (t) = force_fit_type (t, 0);
      }
    return t;
*************** make_bit_field_ref (inner, type, bitsize
*** 2329,2335 ****
       int unsignedp;
  {
    tree result = build (BIT_FIELD_REF, type, inner,
! 		       size_int (bitsize), size_int (bitpos));
  
    TREE_UNSIGNED (result) = unsignedp;
  
--- 2331,2337 ----
       int unsignedp;
  {
    tree result = build (BIT_FIELD_REF, type, inner,
! 		       size_int (bitsize), bitsize_int (bitpos, 0L));
  
    TREE_UNSIGNED (result) = unsignedp;
  
diff -p ../ss-970926/stor-layout.c ./stor-layout.c
*** ../ss-970926/stor-layout.c	Tue Sep 16 15:59:06 1997
--- ./stor-layout.c	Tue Sep 30 16:35:07 1997
*************** Boston, MA 02111-1307, USA.  */
*** 33,39 ****
     It is the first integer type laid out.
     In C, this is int.  */
  
! tree sizetype;
  
  /* An integer constant with value 0 whose type is sizetype.  */
  
--- 33,39 ----
     It is the first integer type laid out.
     In C, this is int.  */
  
! tree sizetype_tab[2], sbitsizetype, ubitsizetype;
  
  /* An integer constant with value 0 whose type is sizetype.  */
  
*************** layout_union (rec)
*** 630,637 ****
  
    /* Determine the ultimate size of the union (in bytes).  */
    if (NULL == var_size)
!     TYPE_SIZE (rec) = size_int (CEIL (const_size, BITS_PER_UNIT)
! 				* BITS_PER_UNIT);
    else if (const_size == 0)
      TYPE_SIZE (rec) = var_size;
    else
--- 630,637 ----
  
    /* Determine the ultimate size of the union (in bytes).  */
    if (NULL == var_size)
!     TYPE_SIZE (rec) = bitsize_int (CEIL (const_size, BITS_PER_UNIT)
! 				   * BITS_PER_UNIT, 0L);
    else if (const_size == 0)
      TYPE_SIZE (rec) = var_size;
    else
*************** layout_type (type)
*** 709,720 ****
  
        TYPE_MODE (type) = smallest_mode_for_size (TYPE_PRECISION (type),
  						 MODE_INT);
!       TYPE_SIZE (type) = size_int (GET_MODE_BITSIZE (TYPE_MODE (type)));
        break;
  
      case REAL_TYPE:
        TYPE_MODE (type) = mode_for_size (TYPE_PRECISION (type), MODE_FLOAT, 0);
!       TYPE_SIZE (type) = size_int (GET_MODE_BITSIZE (TYPE_MODE (type)));
        break;
  
      case COMPLEX_TYPE:
--- 709,720 ----
  
        TYPE_MODE (type) = smallest_mode_for_size (TYPE_PRECISION (type),
  						 MODE_INT);
!       TYPE_SIZE (type) = bitsize_int (GET_MODE_BITSIZE (TYPE_MODE (type)), 0L);
        break;
  
      case REAL_TYPE:
        TYPE_MODE (type) = mode_for_size (TYPE_PRECISION (type), MODE_FLOAT, 0);
!       TYPE_SIZE (type) = bitsize_int (GET_MODE_BITSIZE (TYPE_MODE (type)), 0L);
        break;
  
      case COMPLEX_TYPE:
*************** layout_type (type)
*** 724,730 ****
  			 (TREE_CODE (TREE_TYPE (type)) == INTEGER_TYPE
  			  ? MODE_COMPLEX_INT : MODE_COMPLEX_FLOAT),
  			 0);
!       TYPE_SIZE (type) = size_int (GET_MODE_BITSIZE (TYPE_MODE (type)));
        break;
  
      case VOID_TYPE:
--- 724,730 ----
  			 (TREE_CODE (TREE_TYPE (type)) == INTEGER_TYPE
  			  ? MODE_COMPLEX_INT : MODE_COMPLEX_FLOAT),
  			 0);
!       TYPE_SIZE (type) = bitsize_int (GET_MODE_BITSIZE (TYPE_MODE (type)), 0L);
        break;
  
      case VOID_TYPE:
*************** layout_type (type)
*** 734,740 ****
        break;
  
      case OFFSET_TYPE:
!       TYPE_SIZE (type) = size_int (POINTER_SIZE);
        TYPE_MODE (type) = ptr_mode;
        break;
  
--- 734,740 ----
        break;
  
      case OFFSET_TYPE:
!       TYPE_SIZE (type) = bitsize_int (POINTER_SIZE, 0L);
        TYPE_MODE (type) = ptr_mode;
        break;
  
*************** layout_type (type)
*** 747,753 ****
      case POINTER_TYPE:
      case REFERENCE_TYPE:
        TYPE_MODE (type) = ptr_mode;
!       TYPE_SIZE (type) = size_int (POINTER_SIZE);
        TREE_UNSIGNED (type) = 1;
        TYPE_PRECISION (type) = POINTER_SIZE;
        break;
--- 747,753 ----
      case POINTER_TYPE:
      case REFERENCE_TYPE:
        TYPE_MODE (type) = ptr_mode;
!       TYPE_SIZE (type) = bitsize_int (POINTER_SIZE, 0L);
        TREE_UNSIGNED (type) = 1;
        TYPE_PRECISION (type) = POINTER_SIZE;
        break;
*************** layout_type (type)
*** 795,802 ****
  		&& TREE_CODE (TYPE_MAX_VALUE (index)) != INTEGER_CST)
  	      length = size_binop (MAX_EXPR, length, size_zero_node);
  
! 	    TYPE_SIZE (type) = size_binop (MULT_EXPR, length,
! 					   TYPE_SIZE (element));
  	  }
  
  	/* Now round the alignment and size,
--- 795,802 ----
  		&& TREE_CODE (TYPE_MAX_VALUE (index)) != INTEGER_CST)
  	      length = size_binop (MAX_EXPR, length, size_zero_node);
  
! 	    TYPE_SIZE (type) = size_binop (MULT_EXPR, TYPE_SIZE (element),
! 					   length);
  	  }
  
  	/* Now round the alignment and size,
*************** layout_type (type)
*** 969,975 ****
  	    TYPE_MODE (type) = BLKmode;
  	  else
  	    TYPE_MODE (type) = mode_for_size (alignment, MODE_INT, 1);
! 	  TYPE_SIZE (type) = size_int (rounded_size);
  	  TYPE_ALIGN (type) = alignment;
  	  TYPE_PRECISION (type) = size_in_bits;
  	}
--- 969,975 ----
  	    TYPE_MODE (type) = BLKmode;
  	  else
  	    TYPE_MODE (type) = mode_for_size (alignment, MODE_INT, 1);
! 	  TYPE_SIZE (type) = bitsize_int (rounded_size, 0L);
  	  TYPE_ALIGN (type) = alignment;
  	  TYPE_PRECISION (type) = size_in_bits;
  	}
*************** make_signed_type (precision)
*** 1065,1070 ****
--- 1065,1080 ----
    if (sizetype == 0)
      {
        sizetype = type;
+       /* The *bitsizetype types use a precision that avoids overflows when
+ 	 calculating signed sizes / offsets in bits.  */
+       precision += BITS_PER_UNIT_LOG + 1;
+       /* However, when cross-compiling from a 32 bit to a 64 bit host,
+ 	 we are limited to 64 bit precision.  */
+       if (precision > 2 * HOST_BITS_PER_WIDE_INT)
+ 	precision = 2 * HOST_BITS_PER_WIDE_INT;
+       sbitsizetype = make_signed_type (precision);
+       ubitsizetype = make_unsigned_type (precision);
+       bitsizetype = sbitsizetype;
      }
  
    /* Lay out the type: set its alignment, size, etc.  */
*************** make_unsigned_type (precision)
*** 1090,1095 ****
--- 1100,1108 ----
    if (sizetype == 0)
      {
        sizetype = type;
+       sbitsizetype = make_signed_type (precision + BITS_PER_UNIT_LOG + 1);
+       ubitsizetype = make_unsigned_type (precision + BITS_PER_UNIT_LOG + 1);
+       bitsizetype = ubitsizetype;
      }
  
    fixup_unsigned_type (type);
diff -p ../ss-970926/tree.h ./tree.h
*** ../ss-970926/tree.h	Tue Sep 16 15:59:06 1997
--- ./tree.h	Mon Sep 29 22:23:31 1997
*************** extern tree convert			PROTO((tree, tree)
*** 1387,1400 ****
  extern tree size_in_bytes		PROTO((tree));
  extern int int_size_in_bytes		PROTO((tree));
  extern tree size_binop			PROTO((enum tree_code, tree, tree));
! extern tree size_int			PROTO((unsigned HOST_WIDE_INT));
  extern tree round_up			PROTO((tree, int));
  extern tree get_pending_sizes		PROTO((void));
  extern void put_pending_sizes		PROTO((tree));
  
  /* Type for sizes of data-type.  */
  
! extern tree sizetype;
  
  /* If nonzero, an upper limit on alignment of structure fields, in bits. */
  extern int maximum_field_alignment;
--- 1387,1414 ----
  extern tree size_in_bytes		PROTO((tree));
  extern int int_size_in_bytes		PROTO((tree));
  extern tree size_binop			PROTO((enum tree_code, tree, tree));
! extern tree size_int_wide		PROTO((unsigned HOST_WIDE_INT,
! 					       unsigned HOST_WIDE_INT, int));
! #define size_int(L) size_int_2 ((L), 0, 0)
! #define bitsize_int(L, H) size_int_2 ((L), (H), 1)
! #define size_int_2(L, H, T)			\
!   size_int_wide ((unsigned HOST_WIDE_INT) (L),	\
! 		 (unsigned HOST_WIDE_INT) (H), (T))
! 
  extern tree round_up			PROTO((tree, int));
  extern tree get_pending_sizes		PROTO((void));
  extern void put_pending_sizes		PROTO((tree));
  
  /* Type for sizes of data-type.  */
  
! #define BITS_PER_UNIT_LOG \
!   ((BITS_PER_UNIT > 1) + (BITS_PER_UNIT > 2) + (BITS_PER_UNIT > 4) \
!    + (BITS_PER_UNIT > 8) + (BITS_PER_UNIT > 16) + (BITS_PER_UNIT > 32) \
!    + (BITS_PER_UNIT > 64) + (BITS_PER_UNIT > 128) + (BITS_PER_UNIT > 256))
! 
! extern tree sizetype_tab[2], sbitsizetype, ubitsizetype;
! #define sizetype sizetype_tab[0]
! #define bitsizetype sizetype_tab[1]
  
  /* If nonzero, an upper limit on alignment of structure fields, in bits. */
  extern int maximum_field_alignment;
diff -p ../ss-970926/c-typeck.c ./c-typeck.c
*** ../ss-970926/c-typeck.c	Mon Sep 29 19:33:15 1997
--- ./c-typeck.c	Tue Sep 30 19:56:37 1997
*************** c_sizeof (type)
*** 834,839 ****
--- 834,840 ----
    /* Convert in case a char is more than one unit.  */
    t = size_binop (CEIL_DIV_EXPR, TYPE_SIZE (type), 
  		  size_int (TYPE_PRECISION (char_type_node)));
+   t = convert (sizetype, t);
    /* size_binop does not put the constant in range, so do it now.  */
    if (TREE_CODE (t) == INTEGER_CST && force_fit_type (t, 0))
      TREE_CONSTANT_OVERFLOW (t) = TREE_OVERFLOW (t) = 1;
*************** c_sizeof_nowarn (type)
*** 857,862 ****
--- 858,864 ----
    /* Convert in case a char is more than one unit.  */
    t = size_binop (CEIL_DIV_EXPR, TYPE_SIZE (type), 
  		  size_int (TYPE_PRECISION (char_type_node)));
+   t = convert (sizetype, t);
    force_fit_type (t, 0);
    return t;
  }
*************** c_size_in_bytes (type)
*** 885,890 ****
--- 887,893 ----
    /* Convert in case a char is more than one unit.  */
    t = size_binop (CEIL_DIV_EXPR, TYPE_SIZE (type), 
  		     size_int (BITS_PER_UNIT));
+   t = convert (sizetype, t);
    force_fit_type (t, 0);
    return t;
  }
diff -p ../ss-970926/cp/decl.c cp/decl.c
*** ../ss-970926/cp/decl.c	Mon Sep 29 18:12:16 1997
--- cp/decl.c	Tue Sep 30 16:16:31 1997
*************** init_decl_processing ()
*** 4848,4869 ****
  
    /* `unsigned long' is the standard type for sizeof.
       Note that stddef.h uses `unsigned long',
!      and this must agree, even of long and int are the same size.  */
    sizetype
      = TREE_TYPE (IDENTIFIER_GLOBAL_VALUE (get_identifier (SIZE_TYPE)));
  
    ptrdiff_type_node
      = TREE_TYPE (IDENTIFIER_GLOBAL_VALUE (get_identifier (PTRDIFF_TYPE)));
  
!   TREE_TYPE (TYPE_SIZE (integer_type_node)) = sizetype;
!   TREE_TYPE (TYPE_SIZE (char_type_node)) = sizetype;
!   TREE_TYPE (TYPE_SIZE (unsigned_type_node)) = sizetype;
!   TREE_TYPE (TYPE_SIZE (long_unsigned_type_node)) = sizetype;
!   TREE_TYPE (TYPE_SIZE (long_integer_type_node)) = sizetype;
!   TREE_TYPE (TYPE_SIZE (long_long_integer_type_node)) = sizetype;
!   TREE_TYPE (TYPE_SIZE (long_long_unsigned_type_node)) = sizetype;
!   TREE_TYPE (TYPE_SIZE (short_integer_type_node)) = sizetype;
!   TREE_TYPE (TYPE_SIZE (short_unsigned_type_node)) = sizetype;
  
    /* Define both `signed char' and `unsigned char'.  */
    signed_char_type_node = make_signed_type (CHAR_TYPE_SIZE);
--- 4848,4869 ----
  
    /* `unsigned long' is the standard type for sizeof.
       Note that stddef.h uses `unsigned long',
!      and this must agree, even if long and int are the same size.  */
    sizetype
      = TREE_TYPE (IDENTIFIER_GLOBAL_VALUE (get_identifier (SIZE_TYPE)));
  
    ptrdiff_type_node
      = TREE_TYPE (IDENTIFIER_GLOBAL_VALUE (get_identifier (PTRDIFF_TYPE)));
  
!   TREE_TYPE (TYPE_SIZE (integer_type_node)) = bitsizetype;
!   TREE_TYPE (TYPE_SIZE (char_type_node)) = bitsizetype;
!   TREE_TYPE (TYPE_SIZE (unsigned_type_node)) = bitsizetype;
!   TREE_TYPE (TYPE_SIZE (long_unsigned_type_node)) = bitsizetype;
!   TREE_TYPE (TYPE_SIZE (long_integer_type_node)) = bitsizetype;
!   TREE_TYPE (TYPE_SIZE (long_long_integer_type_node)) = bitsizetype;
!   TREE_TYPE (TYPE_SIZE (long_long_unsigned_type_node)) = bitsizetype;
!   TREE_TYPE (TYPE_SIZE (short_integer_type_node)) = bitsizetype;
!   TREE_TYPE (TYPE_SIZE (short_unsigned_type_node)) = bitsizetype;
  
    /* Define both `signed char' and `unsigned char'.  */
    signed_char_type_node = make_signed_type (CHAR_TYPE_SIZE);
diff -p ../ss-970926/cp/decl2.c cp/decl2.c
*** ../ss-970926/cp/decl2.c	Mon Sep 29 18:12:16 1997
--- cp/decl2.c	Tue Sep 30 15:38:15 1997
*************** finish_builtin_type (type, name, fields,
*** 2312,2319 ****
     `operator new' and `operator delete' correspond to
     what compiler will be expecting.  */
  
- extern tree sizetype;
- 
  tree
  coerce_new_type (type)
       tree type;
--- 2312,2317 ----
*** ../ss-970926/cp/typeck.c	Mon Sep 29 18:12:18 1997
--- cp/typeck.c	Tue Sep 30 19:57:59 1997
*************** c_sizeof (type)
*** 1359,1364 ****
--- 1359,1365 ----
    /* Convert in case a char is more than one unit.  */
    t = size_binop (CEIL_DIV_EXPR, TYPE_SIZE (type), 
  		  size_int (TYPE_PRECISION (char_type_node)));
+   t = convert (sizetype, t);
    /* size_binop does not put the constant in range, so do it now.  */
    if (TREE_CODE (t) == INTEGER_CST && force_fit_type (t, 0))
      TREE_CONSTANT_OVERFLOW (t) = TREE_OVERFLOW (t) = 1;
*************** c_sizeof_nowarn (type)
*** 1416,1421 ****
--- 1417,1423 ----
    /* Convert in case a char is more than one unit.  */
    t = size_binop (CEIL_DIV_EXPR, TYPE_SIZE (type), 
  		  size_int (TYPE_PRECISION (char_type_node)));
+   t = convert (sizetype, t);
    force_fit_type (t, 0);
    return t;
  }



More information about the Gcc mailing list