This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
Patch: fix for PR 7912
- From: Tom Tromey <tromey at redhat dot com>
- To: Java Patch List <java-patches at gcc dot gnu dot org>
- Cc: Gcc Patch List <gcc-patches at gcc dot gnu dot org>
- Date: 03 Nov 2002 18:18:55 -0700
- Subject: Patch: fix for PR 7912
- Reply-to: tromey at redhat dot com
This patch fixes PR 7912.
The bytecode reader didn't know that an array implements Cloneable and
Serializable. I rearranged things a bit so that the necessary
identifiers could be shared with the source front end.
Tested on x86 Red Hat Linux 7.3. Ok?
Tom
Index: ChangeLog
from Tom Tromey <tromey@redhat.com>
Fix for PR java/7912:
* expr.c (can_widen_reference_to): Allow cast of array to
Cloneable or Serializable.
* java-tree.h (enum java_tree_index): New values
JTI_JAVA_LANG_CLONEABLE_IDENTIFIER_NODE,
JTI_JAVA_IO_SERIALIZABLE_IDENTIFIER_NODE.
(java_lang_cloneable_identifier_node): New macro.
(java_io_serializable_identifier_node): Likewise.
* parse.y (java_lang_cloneable, java_io_serializable): Removed.
(valid_ref_assignconv_cast_p): Use new identifier nodes.
* lex.c (java_init_lex): Don't initialize java_lang_cloneable and
java_io_serializable.
* decl.c (java_init_decl_processing): Initialize
java_lang_cloneable_identifier_node and
java_io_serializable_identifier_node.
Index: decl.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/decl.c,v
retrieving revision 1.134
diff -u -r1.134 decl.c
--- decl.c 2 Nov 2002 21:29:36 -0000 1.134
+++ decl.c 4 Nov 2002 01:22:59 -0000
@@ -1,6 +1,6 @@
/* Process declarations and variables for the GNU compiler for the
Java(TM) language.
- Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001
+ Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002
Free Software Foundation, Inc.
This file is part of GNU CC.
@@ -586,6 +586,10 @@
continue_identifier_node = get_identifier ("continue");
access0_identifier_node = get_identifier ("access$0");
classdollar_identifier_node = get_identifier ("class$");
+
+ java_lang_cloneable_identifier_node = get_identifier ("java.lang.Cloneable");
+ java_io_serializable_identifier_node =
+ get_identifier ("java.io.Serializable");
/* for lack of a better place to put this stub call */
init_expr_processing();
Index: expr.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/expr.c,v
retrieving revision 1.152
diff -u -r1.152 expr.c
--- expr.c 27 Sep 2002 18:27:44 -0000 1.152
+++ expr.c 4 Nov 2002 01:23:02 -0000
@@ -1,5 +1,5 @@
/* Process expressions for the GNU compiler for the Java(TM) language.
- Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001
+ Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002
Free Software Foundation, Inc.
This file is part of GNU CC.
@@ -391,7 +391,12 @@
{
HOST_WIDE_INT source_length, target_length;
if (TYPE_ARRAY_P (source_type) != TYPE_ARRAY_P (target_type))
- return 0;
+ {
+ /* An array implements Cloneable and Serializable. */
+ tree name = DECL_NAME (TYPE_NAME (target_type));
+ return (name == java_lang_cloneable_identifier_node
+ || name == java_io_serializable_identifier_node);
+ }
target_length = java_array_type_length (target_type);
if (target_length >= 0)
{
Index: java-tree.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/java-tree.h,v
retrieving revision 1.161
diff -u -r1.161 java-tree.h
--- java-tree.h 2 Nov 2002 23:52:26 -0000 1.161
+++ java-tree.h 4 Nov 2002 01:23:04 -0000
@@ -322,6 +322,8 @@
JTI_CONTINUE_IDENTIFIER_NODE,
JTI_ACCESS0_IDENTIFIER_NODE,
JTI_CLASSDOLLAR_IDENTIFIER_NODE,
+ JTI_JAVA_LANG_CLONEABLE_IDENTIFIER_NODE,
+ JTI_JAVA_IO_SERIALIZABLE_IDENTIFIER_NODE,
JTI_ONE_ELT_ARRAY_DOMAIN_TYPE,
JTI_RETURN_ADDRESS_TYPE_NODE,
@@ -534,6 +536,10 @@
java_global_trees[JTI_ACCESS0_IDENTIFIER_NODE] /* "access$0" */
#define classdollar_identifier_node \
java_global_trees[JTI_CLASSDOLLAR_IDENTIFIER_NODE] /* "class$" */
+#define java_lang_cloneable_identifier_node \
+ java_global_trees[JTI_JAVA_LANG_CLONEABLE_IDENTIFIER_NODE]
+#define java_io_serializable_identifier_node \
+ java_global_trees[JTI_JAVA_IO_SERIALIZABLE_IDENTIFIER_NODE]
#define one_elt_array_domain_type \
java_global_trees[JTI_ONE_ELT_ARRAY_DOMAIN_TYPE]
/* The type of the return address of a subroutine. */
Index: lex.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/lex.c,v
retrieving revision 1.94
diff -u -r1.94 lex.c
--- lex.c 2 Nov 2002 21:29:36 -0000 1.94
+++ lex.c 4 Nov 2002 01:23:05 -0000
@@ -91,10 +91,6 @@
if (!java_lang_id)
java_lang_id = get_identifier ("java.lang");
- if (!java_lang_cloneable)
- java_lang_cloneable = get_identifier ("java.lang.Cloneable");
- if (!java_io_serializable)
- java_io_serializable = get_identifier ("java.io.Serializable");
if (!inst_id)
inst_id = get_identifier ("inst$");
if (!wpv_id)
Index: parse.y
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/parse.y,v
retrieving revision 1.401
diff -u -r1.401 parse.y
--- parse.y 21 Oct 2002 18:26:34 -0000 1.401
+++ parse.y 4 Nov 2002 01:23:17 -0000
@@ -391,12 +391,6 @@
instance/field access functions. */
static GTY(()) tree inst_id;
-/* The "java.lang.Cloneable" qualified name. */
-static GTY(()) tree java_lang_cloneable;
-
-/* The "java.io.Serializable" qualified name. */
-static GTY(()) tree java_io_serializable;
-
/* Context and flag for static blocks */
static GTY(()) tree current_static_block;
@@ -13071,9 +13065,10 @@
{
/* Array */
return (cast
- && (DECL_NAME (TYPE_NAME (source)) == java_lang_cloneable
+ && (DECL_NAME (TYPE_NAME (source))
+ == java_lang_cloneable_identifier_node
|| (DECL_NAME (TYPE_NAME (source))
- == java_io_serializable)));
+ == java_io_serializable_identifier_node)));
}
}
if (TYPE_ARRAY_P (source))
@@ -13083,8 +13078,10 @@
/* Can't cast an array to an interface unless the interface is
java.lang.Cloneable or java.io.Serializable. */
if (TYPE_INTERFACE_P (dest))
- return (DECL_NAME (TYPE_NAME (dest)) == java_lang_cloneable
- || DECL_NAME (TYPE_NAME (dest)) == java_io_serializable);
+ return (DECL_NAME (TYPE_NAME (dest))
+ == java_lang_cloneable_identifier_node
+ || (DECL_NAME (TYPE_NAME (dest))
+ == java_io_serializable_identifier_node));
else /* Arrays */
{
tree source_element_type = TYPE_ARRAY_ELEMENT (source);