Commit 09ed0f70 by Alexandre Petit-Bianco Committed by Alexandre Petit-Bianco

lex.c (java_lang_cloneable): Initialize.

Tue Feb  9 19:31:09 1999  Alexandre Petit-Bianco  <apbianco@cygnus.com>
	* lex.c (java_lang_cloneable): Initialize.
	* parse.y (java_lang_cloneable): New static variable.
	(qualify_ambiguous_name): Take CONVERT_EXPR into account when
 	doing one more qualification round.
	(valid_ref_assignconv_cast_p): Reject null source or
 	destination. Allow an array to be cast into java.lang.Cloneable.
	(patch_cast): Swapped two first arguments to first call to
 	valid_ref_assignconv_cast_p.

From-SVN: r25114
parent 95d62815
Tue Feb 9 19:31:09 1999 Alexandre Petit-Bianco <apbianco@cygnus.com>
* lex.c (java_lang_cloneable): Initialize.
* parse.y (java_lang_cloneable): New static variable.
(qualify_ambiguous_name): Take CONVERT_EXPR into account when
doing one more qualification round.
(valid_ref_assignconv_cast_p): Reject null source or
destination. Allow an array to be cast into java.lang.Cloneable.
(patch_cast): Swapped two first arguments to first call to
valid_ref_assignconv_cast_p.
Mon Feb 8 11:50:50 1999 Alexandre Petit-Bianco <apbianco@cygnus.com> Mon Feb 8 11:50:50 1999 Alexandre Petit-Bianco <apbianco@cygnus.com>
* parse.h: DECL_P renamed JDECL_P. * parse.h: DECL_P renamed JDECL_P.
......
...@@ -79,6 +79,8 @@ java_init_lex () ...@@ -79,6 +79,8 @@ java_init_lex ()
#ifndef JC1_LITE #ifndef JC1_LITE
if (!java_lang_id) if (!java_lang_id)
java_lang_id = get_identifier ("java.lang"); java_lang_id = get_identifier ("java.lang");
if (!java_lang_cloneable)
java_lang_cloneable = get_identifier ("java.lang.Cloneable");
if (!java_lang_imported) if (!java_lang_imported)
{ {
......
...@@ -285,6 +285,9 @@ static tree wfl_to_string = NULL_TREE; ...@@ -285,6 +285,9 @@ static tree wfl_to_string = NULL_TREE;
/* The "java.lang" import qualified name. */ /* The "java.lang" import qualified name. */
static tree java_lang_id = NULL_TREE; static tree java_lang_id = NULL_TREE;
/* The "java.lang.Cloneable" qualified name. */
static tree java_lang_cloneable = NULL_TREE;
%} %}
%union { %union {
...@@ -7335,9 +7338,11 @@ qualify_ambiguous_name (id) ...@@ -7335,9 +7338,11 @@ qualify_ambiguous_name (id)
/* Do one more interation to set things up */ /* Do one more interation to set things up */
super_found = again = 1; super_found = again = 1;
} }
/* Loop one more time if we're dealing with ?: or a string constant */ /* Loop one more time if we're dealing with ?: or a string
constant, or a convert expression */
if (TREE_CODE (qual_wfl) == CONDITIONAL_EXPR if (TREE_CODE (qual_wfl) == CONDITIONAL_EXPR
|| TREE_CODE (qual_wfl) == STRING_CST) || TREE_CODE (qual_wfl) == STRING_CST
|| TREE_CODE (qual_wfl) == CONVERT_EXPR)
{ {
qual = TREE_CHAIN (qual); qual = TREE_CHAIN (qual);
qual_wfl = QUAL_WFL (qual); qual_wfl = QUAL_WFL (qual);
...@@ -8646,6 +8651,9 @@ valid_ref_assignconv_cast_p (source, dest, cast) ...@@ -8646,6 +8651,9 @@ valid_ref_assignconv_cast_p (source, dest, cast)
tree dest; tree dest;
int cast; int cast;
{ {
/* SOURCE or DEST might be null if not from a declared entity. */
if (!source || !dest)
return 0;
if (JNULLP_TYPE_P (source)) if (JNULLP_TYPE_P (source))
return 1; return 1;
if (TREE_CODE (source) == POINTER_TYPE) if (TREE_CODE (source) == POINTER_TYPE)
...@@ -8723,8 +8731,10 @@ valid_ref_assignconv_cast_p (source, dest, cast) ...@@ -8723,8 +8731,10 @@ valid_ref_assignconv_cast_p (source, dest, cast)
{ {
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
java.lang.Cloneable */
if (TYPE_INTERFACE_P (dest)) if (TYPE_INTERFACE_P (dest))
return 0; /* Install test on Clonable. FIXME */ return (DECL_NAME (TYPE_NAME (dest)) == java_lang_cloneable ? 1 : 0);
else /* Arrays */ else /* Arrays */
{ {
tree source_element_type = TYPE_ARRAY_ELEMENT (source); tree source_element_type = TYPE_ARRAY_ELEMENT (source);
...@@ -9672,7 +9682,7 @@ patch_cast (node, wfl_operator) ...@@ -9672,7 +9682,7 @@ patch_cast (node, wfl_operator)
/* The remaining legal casts involve conversion between reference /* The remaining legal casts involve conversion between reference
types. Check for their compile time correctness. */ types. Check for their compile time correctness. */
if (JREFERENCE_TYPE_P (op_type) && JREFERENCE_TYPE_P (cast_type) if (JREFERENCE_TYPE_P (op_type) && JREFERENCE_TYPE_P (cast_type)
&& valid_ref_assignconv_cast_p (cast_type, op_type, 1)) && valid_ref_assignconv_cast_p (op_type, cast_type, 1))
{ {
TREE_TYPE (node) = promote_type (cast_type); TREE_TYPE (node) = promote_type (cast_type);
/* Now, the case can be determined correct at compile time if /* Now, the case can be determined correct at compile time if
......
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