This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
[BC ABI] Fix type signature used in verification
- From: Andrew Haley <aph at redhat dot com>
- To: java-patches at gcc dot gnu dot org, gcc at gcc dot gnu dot org
- Date: Wed, 1 Sep 2004 14:06:31 +0100
- Subject: [BC ABI] Fix type signature used in verification
Tromey found a bug in the way type signatures were generated.
Andrew.
2004-09-01 Andrew Haley <aph@redhat.com>
* expr.c (build_signature_for_libgcj): New function.
(add_type_assertion): Use it to construct signatures for
source_type and target_type.
Index: expr.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/expr.c,v
retrieving revision 1.185.2.9
diff -c -2 -p -r1.185.2.9 expr.c
*** expr.c 27 Aug 2004 19:31:39 -0000 1.185.2.9
--- expr.c 1 Sep 2004 13:01:52 -0000
*************** type_assertion_hash (const void *p)
*** 415,418 ****
--- 415,436 ----
}
+ /* Given a type, return the signature used by
+ _Jv_FindClassFromSignature() in libgcj. This isn't exactly the
+ same as build_java_signature() because we want the canonical array
+ type. */
+
+ static tree
+ build_signature_for_libgcj (tree type)
+ {
+ tree sig, ref;
+
+ if (TYPE_ARRAY_P (type))
+ type = build_java_array_type (TYPE_ARRAY_ELEMENT (type), -1);
+ sig = build_java_signature (type);
+ ref = build_utf8_ref (unmangle_classname (IDENTIFIER_POINTER (sig),
+ IDENTIFIER_LENGTH (sig)));
+ return ref;
+ }
+
/* Add an assertion of the form "source_type is a subclass/
subinterface of target_type" to the "__verify" function of the
*************** add_type_assertion (tree source_type, tr
*** 462,480 ****
{
! tree source_ref, target_ref;
! tree source_sig = build_java_signature(source_type);
! tree target_sig = build_java_signature(target_type);
!
! source_ref
! = build_utf8_ref (unmangle_classname (IDENTIFIER_POINTER (source_sig),
! IDENTIFIER_LENGTH (source_sig)));
! target_ref
! = build_utf8_ref (unmangle_classname (IDENTIFIER_POINTER (target_sig),
! IDENTIFIER_LENGTH (target_sig)));
! tree args = tree_cons (NULL_TREE, source_ref,
! build_tree_list (NULL_TREE, target_ref));
args = chainon (build_tree_list (NULL_TREE, DECL_ARGUMENTS (verify_method)), args);
! tree expr = build (CALL_EXPR, itype,
build_address_of (soft_check_assignment_node),
args, NULL_TREE);
--- 480,491 ----
{
! tree source_ref = build_signature_for_libgcj (source_type);
! tree target_ref = build_signature_for_libgcj (target_type);
! tree args, expr;
! args = tree_cons (NULL_TREE, source_ref,
! build_tree_list (NULL_TREE, target_ref));
args = chainon (build_tree_list (NULL_TREE, DECL_ARGUMENTS (verify_method)), args);
! expr = build (CALL_EXPR, itype,
build_address_of (soft_check_assignment_node),
args, NULL_TREE);