diff options
author | Jeff Sturm <jeff.sturm@commerceone.com> | 2001-02-07 01:46:42 +0000 |
---|---|---|
committer | Alexandre Petit-Bianco <apbianco@gcc.gnu.org> | 2001-02-06 17:46:42 -0800 |
commit | c00dd14e104d2e0fdd8011ff60d3ece69988eabd (patch) | |
tree | a89f5a245c52a6b5a286c619f202b0418eec7f65 /gcc | |
parent | 8480e4804cd9493fe7d3995f194138326a58b4c4 (diff) | |
download | gcc-c00dd14e104d2e0fdd8011ff60d3ece69988eabd.zip gcc-c00dd14e104d2e0fdd8011ff60d3ece69988eabd.tar.gz gcc-c00dd14e104d2e0fdd8011ff60d3ece69988eabd.tar.bz2 |
typeck.c (build_prim_array_type): Added leading comment.
2001-02-05 Jeff Sturm <jeff.sturm@commerceone.com>
Alexandre Petit-Bianco <apbianco@cygnus.com>
* typeck.c (build_prim_array_type): Added leading comment.
(build_java_array_type): Moved locals out of
block. Always create the `data' field, fixed alignment to match
C++.
(http://gcc.gnu.org/ml/gcc-patches/2001-02/msg00378.html)
Co-Authored-By: Alexandre Petit-Bianco <apbianco@cygnus.com>
From-SVN: r39507
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/java/ChangeLog | 8 | ||||
-rw-r--r-- | gcc/java/typeck.c | 45 |
2 files changed, 19 insertions, 34 deletions
diff --git a/gcc/java/ChangeLog b/gcc/java/ChangeLog index de1e16e..5fc513a 100644 --- a/gcc/java/ChangeLog +++ b/gcc/java/ChangeLog @@ -1,3 +1,11 @@ +2001-02-05 Jeff Sturm <jeff.sturm@commerceone.com> + Alexandre Petit-Bianco <apbianco@cygnus.com> + + * typeck.c (build_prim_array_type): Added leading comment. + (build_java_array_type): Moved locals out of + block. Always create the `data' field, fixed alignment to match + C++. + 2001-02-04 Tom Tromey <tromey@redhat.com> * expr.c (java_lang_expand_expr): Don't bother recomputing diff --git a/gcc/java/typeck.c b/gcc/java/typeck.c index e20903d..eb3b533 100644 --- a/gcc/java/typeck.c +++ b/gcc/java/typeck.c @@ -359,6 +359,11 @@ java_array_type_length (array_type) return -1; } +/* An array of unknown length will be ultimately given an length of + -2, so that we can still have `length' producing a negative value + even if found. This was part of an optimization amaing at removing + `length' from static arrays. We could restore it, FIXME. */ + tree build_prim_array_type (element_type, length) tree element_type; @@ -378,7 +383,7 @@ build_java_array_type (element_type, length) tree element_type; HOST_WIDE_INT length; { - tree sig, t, fld; + tree sig, t, fld, atype, arfld; char buf[12]; tree elsig = build_java_signature (element_type); tree el_name = element_type; @@ -416,39 +421,11 @@ build_java_array_type (element_type, length) FIELD_PUBLIC (fld) = 1; FIELD_FINAL (fld) = 1; - if (length >= 0) - { - 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 (fld, desired_align); -#endif - DECL_ALIGN (arfld) = desired_align; - } - } - else - { - 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; - } + atype = build_prim_array_type (element_type, length); + arfld = build_decl (FIELD_DECL, get_identifier ("data"), atype); + DECL_CONTEXT (arfld) = t; + TREE_CHAIN (fld) = arfld; + DECL_ALIGN (arfld) = TYPE_ALIGN (element_type); /* We could layout_class, but that loads java.lang.Object prematurely. * This is called by the parser, and it is a bad idea to do load_class |