Commit 1aca9b81 by Tom Tromey Committed by Tom Tromey

check-init.c (check_init): Don't allow pre- or post- increment or decrement of final variable.

	* check-init.c (check_init): Don't allow pre- or post- increment
	or decrement of final variable.
	(final_assign_error): Minor error message rewording.

From-SVN: r47821
parent 11cb1475
2001-12-09 Tom Tromey <tromey@redhat.com>
* check-init.c (check_init): Don't allow pre- or post- increment
or decrement of final variable.
(final_assign_error): Minor error message rewording.
2001-12-08 Tom Tromey <tromey@redhat.com> 2001-12-08 Tom Tromey <tromey@redhat.com>
* java-tree.h: Fixed typo. * java-tree.h: Fixed typo.
......
...@@ -196,7 +196,7 @@ final_assign_error (name) ...@@ -196,7 +196,7 @@ final_assign_error (name)
tree name; tree name;
{ {
static const char format[] static const char format[]
= "can't re-assign here a value to the final variable '%s'"; = "can't reassign a value to the final variable '%s'";
parse_error_context (wfl, format, IDENTIFIER_POINTER (name)); parse_error_context (wfl, format, IDENTIFIER_POINTER (name));
} }
...@@ -791,10 +791,6 @@ check_init (exp, before) ...@@ -791,10 +791,6 @@ check_init (exp, before)
case FIX_TRUNC_EXPR: case FIX_TRUNC_EXPR:
case INDIRECT_REF: case INDIRECT_REF:
case ADDR_EXPR: case ADDR_EXPR:
case PREDECREMENT_EXPR:
case PREINCREMENT_EXPR:
case POSTDECREMENT_EXPR:
case POSTINCREMENT_EXPR:
case NON_LVALUE_EXPR: case NON_LVALUE_EXPR:
case INSTANCEOF_EXPR: case INSTANCEOF_EXPR:
case FIX_CEIL_EXPR: case FIX_CEIL_EXPR:
...@@ -806,6 +802,18 @@ check_init (exp, before) ...@@ -806,6 +802,18 @@ check_init (exp, before)
exp = TREE_OPERAND (exp, 0); exp = TREE_OPERAND (exp, 0);
goto again; goto again;
case PREDECREMENT_EXPR:
case PREINCREMENT_EXPR:
case POSTDECREMENT_EXPR:
case POSTINCREMENT_EXPR:
tmp = get_variable_decl (TREE_OPERAND (exp, 0));
if (tmp != NULL_TREE && DECL_FINAL (tmp))
final_assign_error (DECL_NAME (tmp));
/* Avoid needless recursion. */
exp = TREE_OPERAND (exp, 0);
goto again;
case SAVE_EXPR: case SAVE_EXPR:
if (IS_INIT_CHECKED (exp)) if (IS_INIT_CHECKED (exp))
return; return;
......
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