diff options
author | aph <> | 2006-08-10 18:35:07 +0000 |
---|---|---|
committer | aph <> | 2006-08-10 18:35:07 +0000 |
commit | 2821e17e8178369eeca3684d194a114ffb3856af (patch) | |
tree | 4e3fd929ca16b78eae9a77bedcc19795582766e9 | |
parent | 288999ce3418a900765602cb5f481627629c08b8 (diff) |
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.
-rw-r--r-- | gcc/java/ChangeLog | 11 | ||||
-rw-r--r-- | gcc/java/parse.y | 23 |
2 files changed, 32 insertions, 2 deletions
diff --git a/gcc/java/ChangeLog b/gcc/java/ChangeLog index 7d83a31a1a6..d1728f82b50 100644 --- a/gcc/java/ChangeLog +++ b/gcc/java/ChangeLog @@ -1,3 +1,14 @@ +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. diff --git a/gcc/java/parse.y b/gcc/java/parse.y index c93a93f94b0..4b6521ca243 100644 --- a/gcc/java/parse.y +++ b/gcc/java/parse.y @@ -12404,7 +12404,18 @@ java_complete_lhs (tree node) 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); @@ -14223,6 +14234,14 @@ build_incdec (int op_token, int op_location, tree op1, int is_post_p) /* 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; } @@ -14377,7 +14396,7 @@ patch_unaryop (tree node, tree wfl_op) 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)) |