Commit ee17a290 by Tom Tromey Committed by Tom Tromey

re GNATS gcj/343 (can't cast array to serializable)

	Fix for PR gcj/343:
	* lex.c (java_init_lex): Initialize java_io_serializable.
	* parse.y (java_io_serializable): New global.
	(valid_ref_assignconv_cast_p): An array can be cast to
	serializable.

From-SVN: r36376
parent 635a2a90
2000-09-12 Tom Tromey <tromey@cygnus.com>
Fix for PR gcj/343:
* lex.c (java_init_lex): Initialize java_io_serializable.
* parse.y (java_io_serializable): New global.
(valid_ref_assignconv_cast_p): An array can be cast to
serializable.
2000-09-10 Zack Weinberg <zack@wolery.cumb.org> 2000-09-10 Zack Weinberg <zack@wolery.cumb.org>
* decl.c, expr.c: Include defaults.h if not already included. * decl.c, expr.c: Include defaults.h if not already included.
......
...@@ -72,6 +72,8 @@ java_init_lex () ...@@ -72,6 +72,8 @@ java_init_lex ()
java_lang_id = get_identifier ("java.lang"); java_lang_id = get_identifier ("java.lang");
if (!java_lang_cloneable) if (!java_lang_cloneable)
java_lang_cloneable = get_identifier ("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) if (!inst_id)
inst_id = get_identifier ("inst$"); inst_id = get_identifier ("inst$");
if (!wpv_id) if (!wpv_id)
......
...@@ -387,6 +387,9 @@ static tree inst_id = NULL_TREE; ...@@ -387,6 +387,9 @@ static tree inst_id = NULL_TREE;
/* The "java.lang.Cloneable" qualified name. */ /* The "java.lang.Cloneable" qualified name. */
static tree java_lang_cloneable = NULL_TREE; static tree java_lang_cloneable = NULL_TREE;
/* The "java.io.Serializable" qualified name. */
static tree java_io_serializable = NULL_TREE;
/* Context and flag for static blocks */ /* Context and flag for static blocks */
static tree current_static_block = NULL_TREE; static tree current_static_block = NULL_TREE;
...@@ -12304,18 +12307,24 @@ valid_ref_assignconv_cast_p (source, dest, cast) ...@@ -12304,18 +12307,24 @@ valid_ref_assignconv_cast_p (source, dest, cast)
else else
return source == dest || interface_of_p (dest, source); return source == dest || interface_of_p (dest, source);
} }
else /* Array */ else
return (cast ? {
(DECL_NAME (TYPE_NAME (source)) == java_lang_cloneable) : 0); /* Array */
return (cast
&& (DECL_NAME (TYPE_NAME (source)) == java_lang_cloneable
|| (DECL_NAME (TYPE_NAME (source))
== java_io_serializable)));
}
} }
if (TYPE_ARRAY_P (source)) if (TYPE_ARRAY_P (source))
{ {
if (TYPE_CLASS_P (dest)) if (TYPE_CLASS_P (dest))
return dest == object_type_node; return dest == object_type_node;
/* Can't cast an array to an interface unless the interface is /* Can't cast an array to an interface unless the interface is
java.lang.Cloneable */ java.lang.Cloneable or java.io.Serializable. */
if (TYPE_INTERFACE_P (dest)) if (TYPE_INTERFACE_P (dest))
return (DECL_NAME (TYPE_NAME (dest)) == java_lang_cloneable ? 1 : 0); return (DECL_NAME (TYPE_NAME (dest)) == java_lang_cloneable
|| DECL_NAME (TYPE_NAME (dest)) == java_io_serializable);
else /* Arrays */ else /* Arrays */
{ {
tree source_element_type = TYPE_ARRAY_ELEMENT (source); tree source_element_type = TYPE_ARRAY_ELEMENT (source);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment