This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
[gcjx] Patch: FYI: array-related tree generation fixes
- From: Tom Tromey <tromey at redhat dot com>
- To: Java Patch List <java-patches at gcc dot gnu dot org>
- Date: 12 Feb 2005 20:48:06 -0700
- Subject: [gcjx] Patch: FYI: array-related tree generation fixes
- Reply-to: tromey at redhat dot com
I'm checking this in on the gcjx branch.
This has a few small tree generation bug fixes related to java array
handling.
- we correctly handle the array's type when building a reference to
an element
- we don't set TYPE_NAME for arrays; this avoids a crash when
computing the fully qualified name of an array... arguably the fix
belongs elsewhere
- we correctly set the type of the "data" field
Tom
#
# patch "gcc/gcc/java/ChangeLog"
# from [34b2ef4056f575716ab3f9634cb392662bf51da8]
# to [58e071fa98227b7f3d0ab3d00f4164858575f025]
#
# patch "gcc/gcc/java/builtins.cc"
# from [0407b9037ce5b0d5cc75d2c9bd74889de0859074]
# to [63397b4659e7efa93355142b3c333b3236ae71f1]
#
# patch "gcc/gcc/java/tree.cc"
# from [24782b5d178caff8cc83b5de93574318f66df72a]
# to [b845207e88959825c85c52cff2bba67992049336]
#
--- gcc/gcc/java/ChangeLog
+++ gcc/gcc/java/ChangeLog
@@ -1,5 +1,10 @@
2005-02-08 Tom Tromey <tromey@redhat.com>
+ * tree.cc (build_array_reference): Correctly handle array's type.
+ * builtins.cc (map_type): Don't set TYPE_NAME for array types.
+ (lay_out_class): Correctly set type of "data" field of array
+ types.
+
* tree.cc (visit_method): Create BIND_EXPR with void type.
* glue.hh: Include function.h.
--- gcc/gcc/java/builtins.cc
+++ gcc/gcc/java/builtins.cc
@@ -232,7 +232,9 @@
else
record = make_node (RECORD_TYPE);
TYPE_BINFO (record) = make_tree_binfo (0);
- TYPE_NAME (record) = map_identifier (klass->get_fully_qualified_name ());
+ if (! klass->array_p ())
+ TYPE_NAME (record)
+ = map_identifier (klass->get_fully_qualified_name ());
// FIXME: make a NAMESPACE_DECL and use it as the DECL_CONTEXT.
@@ -409,8 +411,9 @@
// java, but is needed for code generation.
if (klass->array_p ())
{
+ tree elt_type = map_type (klass->element_type ());
tree data = build_decl (FIELD_DECL, get_identifier ("data"),
- map_type (klass->element_type ()));
+ build_array_type (elt_type, type_jint));
DECL_CONTEXT (data) = klass_record;
TREE_PUBLIC (data) = 1;
DECL_ARTIFICIAL (data) = 1;
--- gcc/gcc/java/tree.cc
+++ gcc/gcc/java/tree.cc
@@ -1963,7 +1963,7 @@
tree result_type,
bool use_checks)
{
- tree array_type = TREE_TYPE (array);
+ tree array_type = TREE_TYPE (TREE_TYPE (array));
// Note that the 'data' field is a back-end invention; it does not
// exist in the model, so we can't look for it there.
tree datafield = gcc_builtins->find_decl (array_type, "data");
@@ -1971,16 +1971,16 @@
array = save_expr (array);
index = save_expr (index);
- tree current
+ tree result
= build4 (ARRAY_REF, result_type,
- build3 (COMPONENT_REF, array_type,
- build1 (INDIRECT_REF, TREE_TYPE (array_type),
+ build3 (COMPONENT_REF, TREE_TYPE (datafield),
+ build1 (INDIRECT_REF, array_type,
gcc_builtins->check_reference (array)),
datafield, NULL_TREE),
index,
NULL_TREE, NULL_TREE);
- TREE_SIDE_EFFECTS (current) = (TREE_SIDE_EFFECTS (array)
- || TREE_SIDE_EFFECTS (index));
+ TREE_SIDE_EFFECTS (result) = (TREE_SIDE_EFFECTS (array)
+ || TREE_SIDE_EFFECTS (index));
if (use_checks && flag_bounds_check)
{
@@ -1990,8 +1990,7 @@
tree length = build3 (COMPONENT_REF, type_jint,
// Note we don't use check_reference here,
// as we it would be redundant.
- build1 (INDIRECT_REF, TREE_TYPE (array_type),
- array),
+ build1 (INDIRECT_REF, array_type, array),
field, NULL_TREE);
tree check = build3 (COND_EXPR, void_type_node,
build2 (GE_EXPR, type_jboolean,
@@ -2001,10 +2000,10 @@
builtin_Jv_ThrowBadArrayIndex,
NULL_TREE, NULL_TREE),
build_empty_stmt ());
- current = build2 (COMPOUND_EXPR, result_type, check, current);
- TREE_SIDE_EFFECTS (current) = (TREE_SIDE_EFFECTS (array)
- || TREE_SIDE_EFFECTS (index));
+ result = build2 (COMPOUND_EXPR, result_type, check, result);
+ TREE_SIDE_EFFECTS (result) = (TREE_SIDE_EFFECTS (array)
+ || TREE_SIDE_EFFECTS (index));
}
- return current;
+ return result;
}