Commit 4a5f66c3 by Alexandre Petit-Bianco Committed by Alexandre Petit-Bianco

decl.c (long_zero_node, [...]): New global variables, initialized.

Thu Dec 10 20:00:54 1998  Alexandre Petit-Bianco  <apbianco@sendai.cygnus.com>
	* decl.c (long_zero_node, float_zero_node, double_zero_node): New
 	global variables, initialized.
	* java-tree.h (long_zero_node, float_zero_node, double_zero_node):
 	Declared new global variables.
	* lex.c (java_lex): Return long_zero_node, float_zero_node,
 	double_zero_node, integer_zero_node upon direct matching.
	* parse.y (purify_type_name): Added function prototype.
	(duplicate_declaration_error_p): Consider new_type as potentially
 	being a incomplete type. Use purify_type_name on type string.
	(method_header): saved_type: unused variable removed. Don't figure
 	return type if method name is invalid.
	(java_complete_tree): Set CAN_COMPLETE_NORMALLY after `node' was
 	processed by patch_unaryop.
	(patch_unaryop): Fixed typo in comment. Re-convert pre/post
 	increment/decrement node into its original type after binary
 	numeric promotion on its operands.
Fixes a bug occuring when an error occurs in constructor
declaration. Fixes a bug on ++/-- operators on non integer operands.

From-SVN: r24255
parent 737e7965
Thu Dec 10 20:00:54 1998 Alexandre Petit-Bianco <apbianco@sendai.cygnus.com>
* decl.c (long_zero_node, float_zero_node, double_zero_node): New
global variables, initialized.
* java-tree.h (long_zero_node, float_zero_node, double_zero_node):
Declared new global variables.
* lex.c (java_lex): Return long_zero_node, float_zero_node,
double_zero_node, integer_zero_node upon direct matching.
* parse.y (purify_type_name): Added function prototype.
(duplicate_declaration_error_p): Consider new_type as potentially
being a incomplete type. Use purify_type_name on type string.
(method_header): saved_type: unused variable removed. Don't figure
return type if method name is invalid.
(java_complete_tree): Set CAN_COMPLETE_NORMALLY after `node' was
processed by patch_unaryop.
(patch_unaryop): Fixed typo in comment. Re-convert pre/post
increment/decrement node into its original type after binary
numeric promotion on its operands.
Thu Dec 10 11:02:49 1998 Alexandre Petit-Bianco <apbianco@cygnus.com>
* parse.y (array_initializer:): Array init operand is NULL_TREE
......
......@@ -316,9 +316,14 @@ tree class_dtable_decl;
tree error_mark_node;
/* Two expressions that are constants with value zero.
The first is of type `int', the second of type `void *'. */
The first is of type `int', the second of type `void *'.
Other of type `long', `float' and `double' follow. */
tree integer_zero_node;
tree null_pointer_node;
tree long_zero_node;
tree float_zero_node;
tree double_zero_node;
tree empty_stmt_node;
/* Nodes for boolean constants TRUE and FALSE. */
......@@ -467,6 +472,9 @@ init_decl_processing ()
integer_four_node = build_int_2 (4, 0);
integer_negative_one_node = build_int_2 (-1, 0);
long_zero_node = build_int_2 (0, 0);
TREE_TYPE (long_zero_node) = long_type_node;
void_type_node = make_node (VOID_TYPE);
pushdecl (build_decl (TYPE_DECL, get_identifier ("void"), void_type_node));
layout_type (void_type_node); /* Uses size_zero_node */
......@@ -524,6 +532,9 @@ init_decl_processing ()
double_type_node));
layout_type (double_type_node);
float_zero_node = build_real (float_type_node, dconst0);
double_zero_node = build_real (double_type_node, dconst0);
unqualified_object_id_node = get_identifier ("Object");
object_type_node = lookup_class (get_identifier ("java.lang.Object"));
object_ptr_type_node = promote_type (object_type_node);
......
......@@ -227,6 +227,9 @@ extern tree return_address_type_node;
extern tree boolean_true_node, boolean_false_node;
/* Integer constants not declared in tree.h. */
extern tree long_zero_node;
extern tree float_zero_node;
extern tree double_zero_node;
extern tree integer_negative_one_node;
extern tree integer_two_node;
extern tree integer_four_node;
......
......@@ -623,19 +623,17 @@ java_lex (java_lval)
switch (c)
{
case 'L': case 'l':
SET_LVAL_NODE_TYPE (integer_zero_node, long_type_node);
SET_LVAL_NODE (long_zero_node);
return (INT_LIT_TK);
case 'f': case 'F':
SET_LVAL_NODE_TYPE (build_real (float_type_node, dconst0),
float_type_node);
SET_LVAL_NODE (float_zero_node);
return (FP_LIT_TK);
case 'd': case 'D':
SET_LVAL_NODE_TYPE (build_real (double_type_node, dconst0),
double_type_node);
SET_LVAL_NODE (double_zero_node);
return (FP_LIT_TK);
default:
java_unget_unicode ();
SET_LVAL_NODE_TYPE (integer_zero_node, int_type_node);
SET_LVAL_NODE (integer_zero_node);
return (INT_LIT_TK);
}
}
......
......@@ -237,6 +237,7 @@ static tree patch_new_array_init PROTO ((tree, tree));
static tree patch_array_constructor PROTO ((tree, tree));
static tree maybe_build_array_element_wfl PROTO ((tree));
static int array_constructor_check_entry PROTO ((tree, tree));
static char *purify_type_name PROTO ((char *));
/* Number of error found so far. */
int java_error_count;
......@@ -3022,10 +3023,15 @@ duplicate_declaration_error_p (new_field_name, new_type, cl)
new_field_name);
if (decl)
{
char *t1 = strdup (lang_printable_name (new_type, 1));
char *t1 = strdup (purify_type_name
((TREE_CODE (new_type) == POINTER_TYPE
&& TREE_TYPE (new_type) == NULL_TREE) ?
IDENTIFIER_POINTER (TYPE_NAME (new_type)) :
lang_printable_name (new_type, 1)));
/* The type may not have been completed by the time we report
the error */
char *t2 = strdup (((TREE_CODE (TREE_TYPE (decl)) == POINTER_TYPE
char *t2 = strdup (purify_type_name
((TREE_CODE (TREE_TYPE (decl)) == POINTER_TYPE
&& TREE_TYPE (TREE_TYPE (decl)) == NULL_TREE) ?
IDENTIFIER_POINTER (TYPE_NAME (TREE_TYPE (decl))) :
lang_printable_name (TREE_TYPE (decl), 1)));
......@@ -3247,7 +3253,7 @@ method_header (flags, type, mdecl, throws)
tree id = TREE_PURPOSE (mdecl);
tree this_class = TREE_TYPE (ctxp->current_parsed_class);
tree type_wfl = NULL_TREE;
tree meth_name, current, orig_arg, saved_type;
tree meth_name = NULL_TREE, current, orig_arg;
int saved_lineno;
int constructor_ok = 0, must_chain;
......@@ -3329,8 +3335,8 @@ method_header (flags, type, mdecl, throws)
/* Do the returned type resolution and registration if necessary */
SET_TYPE_FOR_RESOLUTION (type, type_wfl, must_chain);
saved_type = type;
type = build_array_from_name (type, type_wfl, meth_name, &meth_name);
if (meth_name)
type = build_array_from_name (type, type_wfl, meth_name, &meth_name);
EXPR_WFL_NODE (id) = meth_name;
PROMOTE_RECORD_IF_COMPLETE (type, must_chain);
......@@ -7823,7 +7829,9 @@ java_complete_tree (node)
TREE_OPERAND (node, 0) = java_complete_tree (wfl_op1);
if (TREE_OPERAND (node, 0) == error_mark_node)
return error_mark_node;
return patch_unaryop (node, wfl_op1);
node = patch_unaryop (node, wfl_op1);
CAN_COMPLETE_NORMALLY (node) = 1;
break;
case ARRAY_REF:
/* There are cases were wfl_op1 is a WFL. patch_array_ref knows
......@@ -9301,13 +9309,16 @@ patch_unaryop (node, wfl_op)
}
else
{
/* Before the addition, binary numeric promotion if performed on
/* Before the addition, binary numeric promotion is performed on
both operands */
value = integer_one_node;
prom_type = binary_numeric_promotion (op_type, TREE_TYPE (value),
&op, &value);
/* And write the promoted increment back */
value = build_int_2 (1, 0);
TREE_TYPE (node) =
binary_numeric_promotion (op_type, TREE_TYPE (value), &op, &value);
/* And write the promoted incremented and increment */
TREE_OPERAND (node, 0) = op;
TREE_OPERAND (node, 1) = value;
/* Convert the overall back into its original type. */
return fold (convert (op_type, node));
}
break;
......@@ -9327,7 +9338,7 @@ patch_unaryop (node, wfl_op)
op = do_unary_numeric_promotion (op);
prom_type = TREE_TYPE (op);
if (code == UNARY_PLUS_EXPR)
node = op;
return fold (op);
}
break;
......@@ -9372,18 +9383,18 @@ patch_unaryop (node, wfl_op)
error_found = 1;
}
else
node = value;
return fold (value);
break;
}
if (error_found)
return error_mark_node;
/* In the case of UNARY_PLUS_EXPR, we replaced NODE by a new one */
else if (code != UNARY_PLUS_EXPR && code != CONVERT_EXPR)
{
TREE_OPERAND (node, 0) = op;
TREE_TYPE (node) = prom_type;
}
/* There are cases where node has been replaced by something else
and we don't end up returning here: UNARY_PLUS_EXPR,
CONVERT_EXPR, {POST,PRE}{INCR,DECR}EMENT_EXPR. */
TREE_OPERAND (node, 0) = op;
TREE_TYPE (node) = prom_type;
return fold (node);
}
......
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