[multiple changes]
authorAndrew Haley <aph@redhat.com>
Tue, 14 Jan 2003 13:31:11 +0000 (13:31 +0000)
committerAndrew Haley <aph@gcc.gnu.org>
Tue, 14 Jan 2003 13:31:11 +0000 (13:31 +0000)
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

gcc/java/ChangeLog
gcc/java/decl.c
gcc/java/parse.y

index 958d317988eabbc12012aa20a40b2cccb6bb1d6a..a7d983bd3adae512a809e84d5abe52a14fc7aaa6 100644 (file)
@@ -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.
index d07f83ee098c3fac93bb1db8a6df18e06ebfbb3f..c388539ae99addec79feca898e117b0ca5faea47 100644 (file)
@@ -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),
index dcdcc41ed97f1e80e63fe8738b3e5cb04b18dc30..b618bb273ada603696bb47c17c2cd15435728ef9 100644 (file)
@@ -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;