Fix type mismatches in assignment statements

Andrew Haley aph@redhat.com
Thu Aug 11 11:45:00 GMT 2005


As revealed by Andrew Pinski's GIMPLE verifier.

Andrew.

2005-07-28  Andrew Haley  <aph@redhat.com>

	* java-gimplify.c (java_gimplify_modify_expr): Fix any pointer
	type mismatches to make legal GIMPLE.

Index: gcc/java/java-gimplify.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/java-gimplify.c,v
retrieving revision 1.20
diff -c -2 -p -w -r1.20 java-gimplify.c
*** gcc/java/java-gimplify.c    20 Jul 2005 01:19:42 -0000      1.20
--- gcc/java/java-gimplify.c    11 Aug 2005 11:42:37 -0000
*************** java_gimplify_exit_block_expr (tree expr
*** 209,216 ****
  }
  
- /* This is specific to the bytecode compiler.  If a variable has
-    LOCAL_SLOT_P set, replace an assignment to it with an assignment to
-    the corresponding variable that holds all its aliases.  */
- 
  static tree
  java_gimplify_modify_expr (tree modify_expr)
--- 209,212 ----
*************** java_gimplify_modify_expr (tree modify_e
*** 220,223 ****
--- 216,222 ----
    tree lhs_type = TREE_TYPE (lhs);
  
+   /* This is specific to the bytecode compiler.  If a variable has
+      LOCAL_SLOT_P set, replace an assignment to it with an assignment
+      to the corresponding variable that holds all its aliases.  */
    if (TREE_CODE (lhs) == VAR_DECL
        && DECL_LANG_SPECIFIC (lhs)
*************** java_gimplify_modify_expr (tree modify_e
*** 231,234 ****
--- 230,238 ----
        modify_expr = build1 (NOP_EXPR, lhs_type, modify_expr);
      }
+   else if (lhs_type != TREE_TYPE (rhs))
+     /* Fix up type mismatches to make legal GIMPLE.  These are
+        generated in several places, in particular null pointer
+        assignment and subclass assignment.  */
+     TREE_OPERAND (modify_expr, 1) = convert (lhs_type, rhs);
  
    return modify_expr;



More information about the Java-patches mailing list