Java: fix Array_3 byte compiler failures

Andrew Haley aph@redhat.com
Fri Sep 27 11:27:00 GMT 2002


This fixes the Array_3 test failures and Java/8025.
I committed it.
Andrew.
2002年09月26日 Andrew Haley <aph@redhat.com>
	* expr.c (build_java_array_length_access): Check for null pointer.
	* expr.c (expand_java_arrayload): Likewise.
Index: expr.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/expr.c,v
retrieving revision 1.151
diff -c -2 -p -r1.151 expr.c
*** expr.c	21 Sep 2002 02:19:44 -0000	1.151
--- expr.c	27 Sep 2002 18:25:21 -0000
*************** build_java_array_length_access (node)
*** 676,679 ****
--- 676,688 ----
 HOST_WIDE_INT length;
 
+ /* JVM spec: If the arrayref is null, the arraylength instruction
+ throws a NullPointerException. The only way we could get a node
+ of type ptr_type_node at this point is `aconst_null; arraylength'
+ or something equivalent. */
+ if (type == ptr_type_node)
+ return build (CALL_EXPR, int_type_node, 
+ 		 build_address_of (soft_nullpointer_node),
+ 		 NULL_TREE, NULL_TREE);
+ 
 if (!is_array_type_p (type))
 abort ();
*************** expand_java_arrayload (lhs_type_node )
*** 1029,1038 ****
 index_node = save_expr (index_node);
 array_node = save_expr (array_node);
! lhs_type_node = build_java_check_indexed_type (array_node, lhs_type_node);
! 
! load_node = build_java_arrayaccess (array_node,
! 				 lhs_type_node,
! 				 index_node);
! 
 if (INTEGRAL_TYPE_P (lhs_type_node) && TYPE_PRECISION (lhs_type_node) <= 32)
 load_node = fold (build1 (NOP_EXPR, int_type_node, load_node));
--- 1038,1056 ----
 index_node = save_expr (index_node);
 array_node = save_expr (array_node);
! 
! if (TREE_TYPE (array_node) == ptr_type_node)
! /* The only way we could get a node of type ptr_type_node at this
! point is `aconst_null; arraylength' or something equivalent, so
! unconditionally throw NullPointerException. */ 
! load_node = build (CALL_EXPR, lhs_type_node, 
! 		 build_address_of (soft_nullpointer_node),
! 		 NULL_TREE, NULL_TREE);
! else
! {
! lhs_type_node = build_java_check_indexed_type (array_node, lhs_type_node);
! load_node = build_java_arrayaccess (array_node,
! 					 lhs_type_node,
! 					 index_node);
! }
 if (INTEGRAL_TYPE_P (lhs_type_node) && TYPE_PRECISION (lhs_type_node) <= 32)
 load_node = fold (build1 (NOP_EXPR, int_type_node, load_node));


More information about the Java mailing list

AltStyle によって変換されたページ (->オリジナル) /