This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
Re: PATCH for ConstantValue handling
- To: Per Bothner <per at bothner dot com>
- Subject: Re: PATCH for ConstantValue handling
- From: Alexandre Petit-Bianco <apbianco at cygnus dot com>
- Date: Thu, 30 Aug 2001 19:54:09 -0700 (PDT)
- Cc: gcc-patches at gcc dot gnu dot org, java-patches at gcc dot gnu dot org
- References: <m2d75dw8hz.fsf@eureka.bothner.com>
- Reply-To: apbianco at cygnus dot com
Per Bothner writes:
> Note the patch is a work-around for front-end errors. At least we
> now generate valid code for valid Java. However, the compiler still
> silently accepts:
> final static long x = 2.5;
I have a patch for that. I've been testing it a bit.
./A
2001-08-30 Alexandre Petit-Bianco <apbianco@redhat.com>
* parse.y (patch_assignment): Don't verify final re-assignment here.
(java_complete_lhs): Verify assignments to finals calling
`patch_assignment.' Verify re-assignments to finals before
calling patch_assignment.
Index: parse.y
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/parse.y,v
retrieving revision 1.304
diff -u -p -r1.304 parse.y
--- parse.y 2001/08/29 02:22:52 1.304
+++ parse.y 2001/08/31 02:46:10
@@ -11897,11 +11901,15 @@ java_complete_lhs (node)
value = fold_constant_for_init (nn, nn);
- if (value != NULL_TREE)
+ if (value != NULL_TREE &&
+ (JPRIMITIVE_TYPE_P (TREE_TYPE (value)) ||
+ (TREE_TYPE (value) == string_ptr_type_node &&
+ ! flag_emit_class_files)))
{
- tree type = TREE_TYPE (value);
- if (JPRIMITIVE_TYPE_P (type) ||
- (type == string_ptr_type_node && ! flag_emit_class_files))
+ TREE_OPERAND (node, 1) = value;
+ if (patch_assignment (node, wfl_op1, value) == error_mark_node)
+ return error_mark_node;
+ else
return empty_stmt_node;
}
if (! flag_emit_class_files)
@@ -11985,6 +11993,9 @@ java_complete_lhs (node)
}
else
{
+ /* Can't assign to a (blank) final. */
+ if (check_final_assignment (TREE_OPERAND (node, 0), wfl_op1))
+ return error_mark_node;
node = patch_assignment (node, wfl_op1, wfl_op2);
/* Reorganize the tree if necessary. */
if (flag && (!JREFERENCE_TYPE_P (TREE_TYPE (node))
@@ -12761,10 +12772,6 @@ patch_assignment (node, wfl_op1, wfl_op2
int error_found = 0;
int lvalue_from_array = 0;
- /* Can't assign to a (blank) final. */
- if (check_final_assignment (lvalue, wfl_op1))
- error_found = 1;
-
EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (node);
/* Lhs can be a named variable */