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
This commit is contained in:
Andrew Haley 2000-08-29 22:15:21 +00:00 committed by Alexandre Petit-Bianco
parent 7efcf4662e
commit 65f69237d7
2 changed files with 30 additions and 2 deletions

View File

@ -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'.

View File

@ -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 ();