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


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

bootstrap fix


Howdy,

A recent change[1] broke gcj's handling of arrays, which caused my
bootstrap attempts to fail.  Alexandre Petit-Bianco noted that the
problem was gcj's representation of empty arrays by a -1 size[2].
Looking through stor-layout.c, it expects empty and variable sized
arrays to have no index field.  The changes to java/typeck.c make
it follow this convention.

The array is then embedded in a record, preceded by the length.
But since the array size is still not known (and hence NULL),
host_integerp segfaulted when called on the array size.  So if the
array size isn't yet known, default to BLKmode.

This bootstrapped on i686-pc-linux-gnu.  I ran the testsuite, and
it compiled ArrayClass.java successfully.

OK to commit?

Matt

1. http://gcc.gnu.org/ml/gcc-patches/2001-09/msg00120.html
2. http://gcc.gnu.org/ml/gcc/2001-09/msg00131.html

java/ChangeLog:

	* typeck.c (java_array_type_length, build_prim_array_type):
	Represent empty arrays by NULL index.

ChangeLog:

	* stor-layout.c (compute_record_mode): Check DECL_SIZE is set.

Index: gcc/stor-layout.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/stor-layout.c,v
retrieving revision 1.104
diff -c -3 -p -r1.104 stor-layout.c
*** stor-layout.c	2001/09/05 13:16:44	1.104
--- stor-layout.c	2001/09/06 20:53:11
*************** compute_record_mode (type)
*** 1110,1115 ****
--- 1110,1116 ----
  	  || (TYPE_MODE (TREE_TYPE (field)) == BLKmode
  	      && ! TYPE_NO_FORCE_BLK (TREE_TYPE (field)))
  	  || ! host_integerp (bit_position (field), 1)
+ 	  || DECL_SIZE (field) == 0
  	  || ! host_integerp (DECL_SIZE (field), 1))
  	return;
  
Index: gcc/java/typeck.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/typeck.c,v
retrieving revision 1.42
diff -c -3 -p -r1.42 typeck.c
*** typeck.c	2001/04/29 11:24:37	1.42
--- typeck.c	2001/09/06 20:53:11
*************** java_array_type_length (array_type)
*** 353,361 ****
    if (arfld != NULL_TREE)
      {
        tree index_type = TYPE_DOMAIN (TREE_TYPE (arfld));
!       tree high = TYPE_MAX_VALUE (index_type);
!       if (TREE_CODE (high) == INTEGER_CST)
! 	return TREE_INT_CST_LOW (high) + 1;
      }
    return -1;
  }
--- 353,364 ----
    if (arfld != NULL_TREE)
      {
        tree index_type = TYPE_DOMAIN (TREE_TYPE (arfld));
!       if (index_type != NULL_TREE)
! 	{
! 	  tree high = TYPE_MAX_VALUE (index_type);
! 	  if (TREE_CODE (high) == INTEGER_CST)
! 	    return TREE_INT_CST_LOW (high) + 1;
! 	}
      }
    return -1;
  }
*************** build_prim_array_type (element_type, len
*** 370,378 ****
       tree element_type;
       HOST_WIDE_INT length;
  {
!   tree max_index = build_int_2 (length - 1, (0 == length ? -1 : 0));
!   TREE_TYPE (max_index) = sizetype;
!   return build_array_type (element_type, build_index_type (max_index));
  }
  
  /* Return a Java array type with a given ELEMENT_TYPE and LENGTH.
--- 373,387 ----
       tree element_type;
       HOST_WIDE_INT length;
  {
!   tree index = NULL;
! 
!   if (length != -1)
!     {
!       tree max_index = build_int_2 (length - 1, (0 == length ? -1 : 0));
!       TREE_TYPE (max_index) = sizetype;
!       index = build_index_type (max_index);
!     }
!   return build_array_type (element_type, index);
  }
  
  /* Return a Java array type with a given ELEMENT_TYPE and LENGTH.


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