This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH][java] Fix type problems in the Java frontend
- From: Richard Guenther <rguenther at suse dot de>
- To: gcc-patches at gcc dot gnu dot org
- Date: Wed, 11 Jul 2007 18:16:15 +0200 (CEST)
- Subject: [PATCH][java] Fix type problems in the Java frontend
This fixes all type problems found in the Java frontend by the
gimple type verifier. It allows bootstrapping Java with it switched on.
Bootstrapped and tested on x86_64-unknown-linux-gnu.
Ok for mainline?
(It looks like there is funny stuff going on in the FE - it does
the equivalent of *(T **)p with p of type (T *). This may ask for
trouble with aliasing.)
Thanks,
Richard.
:ADDPATCH java:
2007-07-11 Richard Guenther <rguenther@suse.de>
* expr.c (expand_java_return): RETURN_EXPR has void type.
(build_jni_stub): Likewise. Use a comparison against zero
for null-pointer test in COND_EXPR.
(build_field_ref): Build POINTER_PLUS_EXPR with correct
type. Convert result instead.
(build_invokevirtual): Likewise.
Index: gcc/java/expr.c
===================================================================
*** gcc.orig/java/expr.c 2007-07-11 13:26:00.000000000 +0200
--- gcc/java/expr.c 2007-07-11 16:30:30.000000000 +0200
*************** expand_java_return (tree type)
*** 1286,1292 ****
retval = build1(NOP_EXPR, TREE_TYPE(res), retval);
TREE_SIDE_EFFECTS (retval) = 1;
! java_add_stmt (build1 (RETURN_EXPR, TREE_TYPE (retval), retval));
}
}
--- 1286,1292 ----
retval = build1(NOP_EXPR, TREE_TYPE(res), retval);
TREE_SIDE_EFFECTS (retval) = 1;
! java_add_stmt (build1 (RETURN_EXPR, void_type_node, retval));
}
}
*************** build_field_ref (tree self_value, tree s
*** 1744,1751 ****
self_value = java_check_reference (self_value, check);
address
= fold_build2 (POINTER_PLUS_EXPR,
! build_pointer_type (TREE_TYPE (field_decl)),
self_value, field_offset);
return fold_build1 (INDIRECT_REF, TREE_TYPE (field_decl), address);
}
--- 1744,1753 ----
self_value = java_check_reference (self_value, check);
address
= fold_build2 (POINTER_PLUS_EXPR,
! TREE_TYPE (self_value),
self_value, field_offset);
+ address = fold_convert (build_pointer_type (TREE_TYPE (field_decl)),
+ address);
return fold_build1 (INDIRECT_REF, TREE_TYPE (field_decl), address);
}
*************** build_invokevirtual (tree dtable, tree m
*** 2332,2344 ****
size_int (TARGET_VTABLE_USES_DESCRIPTORS));
}
! func = fold_build2 (POINTER_PLUS_EXPR, nativecode_ptr_ptr_type_node, dtable,
convert (sizetype, method_index));
if (TARGET_VTABLE_USES_DESCRIPTORS)
func = build1 (NOP_EXPR, nativecode_ptr_type_node, func);
else
! func = build1 (INDIRECT_REF, nativecode_ptr_type_node, func);
return func;
}
--- 2334,2349 ----
size_int (TARGET_VTABLE_USES_DESCRIPTORS));
}
! func = fold_build2 (POINTER_PLUS_EXPR, TREE_TYPE (dtable), dtable,
convert (sizetype, method_index));
if (TARGET_VTABLE_USES_DESCRIPTORS)
func = build1 (NOP_EXPR, nativecode_ptr_type_node, func);
else
! {
! func = fold_convert (nativecode_ptr_ptr_type_node, func);
! func = build1 (INDIRECT_REF, nativecode_ptr_type_node, func);
! }
return func;
}
*************** build_jni_stub (tree method)
*** 2715,2721 ****
jni_func_type = build_pointer_type (tem);
jnifunc = build3 (COND_EXPR, ptr_type_node,
! meth_var, meth_var,
build2 (MODIFY_EXPR, ptr_type_node, meth_var,
build_call_nary (ptr_type_node,
build_address_of
--- 2720,2728 ----
jni_func_type = build_pointer_type (tem);
jnifunc = build3 (COND_EXPR, ptr_type_node,
! build2 (NE_EXPR, boolean_type_node,
! meth_var, build_int_cst (TREE_TYPE (meth_var), 0)),
! meth_var,
build2 (MODIFY_EXPR, ptr_type_node, meth_var,
build_call_nary (ptr_type_node,
build_address_of
*************** build_jni_stub (tree method)
*** 2777,2783 ****
}
body = build2 (COMPOUND_EXPR, void_type_node, body,
! build1 (RETURN_EXPR, res_type, res_var));
TREE_SIDE_EFFECTS (body) = 1;
/* Prepend class initialization for static methods reachable from
--- 2784,2790 ----
}
body = build2 (COMPOUND_EXPR, void_type_node, body,
! build1 (RETURN_EXPR, void_type_node, res_var));
TREE_SIDE_EFFECTS (body) = 1;
/* Prepend class initialization for static methods reachable from