diff options
author | Andrew Haley <aph@cygnus.com> | 2000-08-29 22:15:21 +0000 |
---|---|---|
committer | Alexandre Petit-Bianco <apbianco@gcc.gnu.org> | 2000-08-29 15:15:21 -0700 |
commit | 65f69237d7a0a3883ab120593c372fed53613b35 (patch) | |
tree | 2535202ed384f0558a94feb08a4c14605880a4fd /gcc | |
parent | 7efcf4662e9bf7ac58f09ef7184c34f077ea85ae (diff) | |
download | gcc-65f69237d7a0a3883ab120593c372fed53613b35.zip gcc-65f69237d7a0a3883ab120593c372fed53613b35.tar.gz gcc-65f69237d7a0a3883ab120593c372fed53613b35.tar.bz2 |
typeck.c (build_java_array_type): Rewrite code to do array alignment.
2000-08-16 Andrew Haley <aph@cygnus.com>
* typeck.c (build_java_array_type): Rewrite code to do array
alignment. Take into account back-end macros when aligning array
data. Remove setting of TYPE_USER_ALIGN; Java doesn't allow the
user to set alignment. Fixes gcj/252 and 160.
(This fixes gcj/252 and 160:
http://sources.redhat.com/ml/java-prs/2000-q2/msg00254.html
<couldn't find an archive entry for gcj/160>
http://gcc.gnu.org/ml/gcc-patches/2000-08/msg00907.html)
From-SVN: r36057
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/java/ChangeLog | 7 | ||||
-rw-r--r-- | gcc/java/typeck.c | 25 |
2 files changed, 30 insertions, 2 deletions
diff --git a/gcc/java/ChangeLog b/gcc/java/ChangeLog index 4dfa874..754112a 100644 --- a/gcc/java/ChangeLog +++ b/gcc/java/ChangeLog @@ -35,6 +35,13 @@ * lang-specs.h: Do not process -o or run the assembler if -fsyntax-only. +2000-08-16 Andrew Haley <aph@cygnus.com> + + * typeck.c (build_java_array_type): Rewrite code to do array + alignment. Take into account back-end macros when aligning array + data. Remove setting of TYPE_USER_ALIGN; Java doesn't allow the + user to set alignment. Fixes gcj/252 and 160. + 2000-08-09 Tom Tromey <tromey@cygnus.com> * parse.y (check_abstract_method_definitions): Now return `int'. diff --git a/gcc/java/typeck.c b/gcc/java/typeck.c index 1a7256d..990ff06 100644 --- a/gcc/java/typeck.c +++ b/gcc/java/typeck.c @@ -417,13 +417,34 @@ build_java_array_type (element_type, length) { tree atype = build_prim_array_type (element_type, length); tree arfld = build_decl (FIELD_DECL, get_identifier ("data"), atype); + DECL_CONTEXT (arfld) = t; TREE_CHAIN (fld) = arfld; + + /* We need to force the data field to begin at an alignment at + least equal to the biggest alignment in an object type node + in order to be compatible with the way that JArray is defined + in CNI. However, we can't exceed BIGGEST_FIELD_ALIGNMENT. */ + { + unsigned desired_align = TYPE_ALIGN (object_type_node); + desired_align = MAX (desired_align, TYPE_ALIGN (element_type)); +#ifdef BIGGEST_FIELD_ALIGNMENT + desired_align = MIN (desired_align, + (unsigned) BIGGEST_FIELD_ALIGNMENT); +#endif +#ifdef ADJUST_FIELD_ALIGN + desired_align = ADJUST_FIELD_ALIGN (field, desired_align); +#endif + DECL_ALIGN (arfld) = desired_align; + } } else { - TYPE_ALIGN (t) = TYPE_ALIGN (element_type); - TYPE_USER_ALIGN (t) = TYPE_USER_ALIGN (element_type); + unsigned desired_align = TYPE_ALIGN (element_type); +#ifdef BIGGEST_FIELD_ALIGNMENT + desired_align = MIN (desired_align, (unsigned) BIGGEST_FIELD_ALIGNMENT); +#endif + TYPE_ALIGN (t) = desired_align; } pop_obstacks (); |