aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorAndrew Haley <aph@redhat.com>2003-01-14 13:31:11 +0000
committerAndrew Haley <aph@gcc.gnu.org>2003-01-14 13:31:11 +0000
commit50cbc6057f519f2d0af68c95cf37e45d396009c2 (patch)
treeadf750741436d54577476b5594ab5c705dbfa822 /gcc
parent4d77fda24b78067384db548c55e5cb7b0bce0e44 (diff)
downloadgcc-50cbc6057f519f2d0af68c95cf37e45d396009c2.zip
gcc-50cbc6057f519f2d0af68c95cf37e45d396009c2.tar.gz
gcc-50cbc6057f519f2d0af68c95cf37e45d396009c2.tar.bz2
[multiple changes]
2003-01-14 Andrew Haley <aph@redhat.com> * decl.c (java_init_decl_processing): _Jv_NewMultiArray is a varargs function -- correct. * parse.y (patch_assignment): Copy the rhs of an assignment into a temporary if the RHS is a reference. 2003-01-11 Kaveh R. Ghazi <ghazi@caip.rutgers.edu> * Make-lang.in (keyword.h): Pass "-L ANSI-C" to gperf. * keyword.h: Regenerated. * All Files: Convert to ISO C style function definitions. From-SVN: r61281
Diffstat (limited to 'gcc')
-rw-r--r--gcc/java/ChangeLog8
-rw-r--r--gcc/java/decl.c5
-rw-r--r--gcc/java/parse.y37
3 files changed, 48 insertions, 2 deletions
diff --git a/gcc/java/ChangeLog b/gcc/java/ChangeLog
index 958d317..a7d983b 100644
--- a/gcc/java/ChangeLog
+++ b/gcc/java/ChangeLog
@@ -1,3 +1,11 @@
+2003-01-14 Andrew Haley <aph@redhat.com>
+
+ * decl.c (java_init_decl_processing): _Jv_NewMultiArray is a
+ varargs function -- correct.
+
+ * parse.y (patch_assignment): Copy the rhs of an assignment into a
+ temporary if the RHS is a reference.
+
2003-01-11 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
* Make-lang.in (keyword.h): Pass "-L ANSI-C" to gperf.
diff --git a/gcc/java/decl.c b/gcc/java/decl.c
index d07f83e..c388539 100644
--- a/gcc/java/decl.c
+++ b/gcc/java/decl.c
@@ -810,8 +810,9 @@ java_init_decl_processing (void)
0, NOT_BUILT_IN, NULL, NULL_TREE);
DECL_IS_MALLOC (soft_anewarray_node) = 1;
- t = tree_cons (NULL_TREE, ptr_type_node,
- tree_cons (NULL_TREE, int_type_node, endlink));
+ /* There is no endlink here because _Jv_NewMultiArray is a varargs
+ function. */
+ t = tree_cons (NULL_TREE, ptr_type_node, int_type_node);
soft_multianewarray_node
= builtin_function ("_Jv_NewMultiArray",
build_function_type (ptr_type_node, t),
diff --git a/gcc/java/parse.y b/gcc/java/parse.y
index dcdcc41..b618bb2 100644
--- a/gcc/java/parse.y
+++ b/gcc/java/parse.y
@@ -12627,6 +12627,43 @@ patch_assignment (tree node, tree wfl_op1)
DECL_INITIAL (lvalue) = new_rhs;
}
+ /* Copy the rhs if it's a reference. */
+ if (! flag_check_references && optimize > 0)
+ {
+ switch (TREE_CODE (new_rhs))
+ {
+ case ARRAY_REF:
+ case INDIRECT_REF:
+ case COMPONENT_REF:
+ /* Transform a = foo.bar
+ into a = { int tmp; tmp = foo.bar; tmp; ).
+ We need to ensure that if a read from memory fails
+ because of a NullPointerException, a destination variable
+ will remain unchanged. An explicit temporary does what
+ we need.
+
+ If flag_check_references is set, this is unnecessary
+ because we'll check each reference before doing any
+ reads. If optimize is not set the result will never be
+ written to a stack slot that contains the LHS. */
+ {
+ tree tmp = build_decl (VAR_DECL, get_identifier ("<tmp>"),
+ TREE_TYPE (new_rhs));
+ tree block = build (BLOCK, TREE_TYPE (new_rhs), NULL);
+ tree assignment
+ = build (MODIFY_EXPR, TREE_TYPE (new_rhs), tmp, fold (new_rhs));
+ BLOCK_VARS (block) = tmp;
+ BLOCK_EXPR_BODY (block)
+ = build (COMPOUND_EXPR, TREE_TYPE (new_rhs), assignment, tmp);
+ TREE_SIDE_EFFECTS (block) = 1;
+ new_rhs = block;
+ }
+ break;
+ default:
+ break;
+ }
+ }
+
TREE_OPERAND (node, 0) = lvalue;
TREE_OPERAND (node, 1) = new_rhs;
TREE_TYPE (node) = lhs_type;