[tree-ssa] fix java Array_3 and friends
Andrew Haley
aph@redhat.com
Mon May 10 14:38:00 GMT 2004
Fixes for String_overflow and err3.
Andrew.
2004-05-10 Andrew Haley <aph@redhat.com>
* java-gimplify.c (java_gimplify_expr): Copy the LHS of a binary
expression into a temporary variable.
(java_gimplify_new_array_init): Set the DECL_CONTEXT of array and
tmp to current_function_decl.
Index: java-gimplify.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/Attic/java-gimplify.c,v
retrieving revision 1.1.2.11
diff -c -2 -p -r1.1.2.11 java-gimplify.c
*** java-gimplify.c 24 Feb 2004 09:25:38 -0000 1.1.2.11
--- java-gimplify.c 10 May 2004 14:02:07 -0000
*************** java_gimplify_expr (tree *expr_p, tree *
*** 61,64 ****
--- 61,85 ----
tree *post_p ATTRIBUTE_UNUSED)
{
+ char code_class = TREE_CODE_CLASS(TREE_CODE (*expr_p));
+
+ /* Java insists on strict left-to-right evaluation of expressions.
+ A problem may arise if a variable used in the lhs of a binary
+ operation is altered by an assignment to that value in the rhs
+ before we've performed the operation. So, we always copy every
+ LHS to a temprorary variable.
+
+ FIXME: Are there any other cases where we should do this?
+ Parameter lists, maybe? Or perhaps that's unnecessary because
+ the front end already generates SAVE_EXPRs. */
+ if (code_class == '2')
+ {
+ tree lhs = TREE_OPERAND (*expr_p, 0);
+ enum gimplify_status stat
+ = gimplify_expr (&lhs, pre_p, post_p, is_gimple_tmp_var, fb_rvalue);
+ if (stat == GS_ERROR)
+ return stat;
+ TREE_OPERAND (*expr_p, 0) = lhs;
+ }
+
switch (TREE_CODE (*expr_p))
{
*************** java_gimplify_new_array_init (tree exp)
*** 187,190 ****
--- 208,214 ----
int index = 0;
+
+ DECL_CONTEXT (array) = current_function_decl;
+ DECL_CONTEXT (tmp) = current_function_decl;
/* FIXME: try to allocate array statically? */
More information about the Gcc-patches
mailing list