+2006-08-10 Simon Martin <simartin@users.sourceforge.net>
+
+ PR java/8923
+ * parse.y (build_incdec): Emit an error instead of an ICE if '++'
+ or '--' is used with a constant operand.
+ (java_complete_lhs): When processing a '++' or '--' expression,
+ don't call java_complete_tree but java_complete_lhs, so that a
+ static final variable operand is never replaced by its value. This
+ avoids an ICE later on.
+ (patch_unaryop): Fixed typo in comment.
+
2006-07-28 Volker Reichelt <reichelt@igpm.rwth-aachen.de>
* Make-lang.in: Use $(HEADER_H) instead of header.h in dependencies.
how to handle those cases. */
wfl_op1 = TREE_OPERAND (node, 0);
CAN_COMPLETE_NORMALLY (node) = 1;
- TREE_OPERAND (node, 0) = java_complete_tree (wfl_op1);
+ if (TREE_CODE (node) == PREDECREMENT_EXPR
+ || TREE_CODE (node) == PREINCREMENT_EXPR
+ || TREE_CODE (node) == POSTDECREMENT_EXPR
+ || TREE_CODE (node) == POSTINCREMENT_EXPR)
+ { /* We don't want static finals to be resolved to their value
+ to avoid ICEing later. It solves PR8923. */
+ TREE_OPERAND (node, 0) = java_complete_lhs (wfl_op1);
+ }
+ else
+ {
+ TREE_OPERAND (node, 0) = java_complete_tree (wfl_op1);
+ }
if (TREE_OPERAND (node, 0) == error_mark_node)
return error_mark_node;
node = patch_unaryop (node, wfl_op1);
/* Store the location of the operator, for better error report. The
string of the operator will be rebuild based on the OP value. */
EXPR_WFL_LINECOL (node) = op_location;
+
+ /* Report an error if the operand is a constant. */
+ if (TREE_CONSTANT (op1)) {
+ parse_error_context (node, "%qs cannot be used with a constant",
+ operator_string (node));
+ return error_mark_node;
+ }
+
return node;
}
error_found = 1;
}
- /* From now on, we know that op if a variable and that it has a
+ /* From now on, we know that op is a variable and that it has a
valid wfl. We use wfl_op to locate errors related to the
++/-- operand. */
if (!JNUMERIC_TYPE_P (op_type))