* jcf-dump.c (SPECIAL_IINC): Remove unneeded casts to long.
+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.
+
+2001-08-29 Alexandre Petit-Bianco <apbianco@redhat.com>
+
+ * parse.y (java_complete_lhs): Allow final locals in CASE_EXPRs.
+ Fixes PR java/1413
+
+2001-08-28 Alexandre Petit-Bianco <apbianco@redhat.com>
+
+ * lex.c (java_lex): new local found_hex_digits. Set and then used
+ in test to reject invalid hexadecimal numbers.
+ * parse.y (java_complete_tree): Prevent unwanted cast with
+ initialized floating point finals.
+ (patch_binop): Emit a warning when detecting a division by zero,
+ mark result not constant, don't simplify non integer division.
+
2001-08-28 Per Bothner <per@bothner.com>
* jcf-write.c (generate_bytecode_insns): For increments and
/* End borrowed section */
char literal_token [256];
int literal_index = 0, radix = 10, long_suffix = 0, overflow = 0, bytes;
+ int found_hex_digits = 0;
int i;
#ifndef JC1_LITE
int number_beginning = ctxp->c_line->current;
int numeric = (RANGE (c, '0', '9') ? c-'0' : 10 +(c|0x20)-'a');
int count;
+ /* Remember when we find a valid hexadecimal digit */
+ if (radix == 16)
+ found_hex_digits = 1;
+
literal_token [literal_index++] = c;
/* This section of code if borrowed from gcc/c-lex.c */
for (count = 0; count < TOTAL_PARTS; count++)
}
} /* JAVA_ASCCI_FPCHAR (c) */
+ if (radix == 16 && ! found_hex_digits)
+ java_lex_error
+ ("0x must be followed by at least one hexadecimal digit", 0);
+
/* Here we get back to converting the integral literal. */
if (c == 'L' || c == 'l')
long_suffix = 1;
/* fold_constant_for_init sometimes widen the original type
of the constant (i.e. byte to int.) It's not desirable,
especially if NODE is a function argument. */
- if (TREE_CODE (value) == INTEGER_CST
+ if ((TREE_CODE (value) == INTEGER_CST
+ || TREE_CODE (value) == REAL_CST)
&& TREE_TYPE (node) != TREE_TYPE (value))
return convert (TREE_TYPE (node), value);
else
cn = fold_constant_for_init (DECL_INITIAL (TREE_OPERAND (cn, 1)),
TREE_OPERAND (cn, 1));
}
+ /* Accept final locals too. */
+ else if (TREE_CODE (cn) == VAR_DECL && LOCAL_FINAL (cn))
+ cn = fold_constant_for_init (DECL_INITIAL (cn), cn);
if (!TREE_CONSTANT (cn) && !flag_emit_xref)
{
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)
}
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))
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 */
(TREE_CODE (op2) == INTEGER_CST &&
! TREE_INT_CST_LOW (op2) && ! TREE_INT_CST_HIGH (op2))))
{
- parse_error_context (wfl_operator, "Arithmetic exception");
- error_found = 1;
+ parse_warning_context (wfl_operator, "Evaluating this expression will result in an arithmetic exception being thrown.");
+ TREE_CONSTANT (node) = 0;
}
/* Change the division operator if necessary */
TREE_SET_CODE (node, TRUNC_DIV_EXPR);
/* Before divisions as is disapear, try to simplify and bail if
- applicable, otherwise we won't perform even simple simplifications
- like (1-1)/3. */
- if (code == RDIV_EXPR && TREE_CONSTANT (op1) && TREE_CONSTANT (op2))
+ applicable, otherwise we won't perform even simple
+ simplifications like (1-1)/3. We can't do that with floating
+ point number, folds can't handle them at this stage. */
+ if (code == RDIV_EXPR && TREE_CONSTANT (op1) && TREE_CONSTANT (op2)
+ && JINTEGRAL_TYPE_P (op1) && JINTEGRAL_TYPE_P (op2))
{
TREE_TYPE (node) = prom_type;
node = fold (node);