diff options
author | Tom Tromey <tromey@redhat.com> | 2001-12-09 23:43:19 +0000 |
---|---|---|
committer | Tom Tromey <tromey@gcc.gnu.org> | 2001-12-09 23:43:19 +0000 |
commit | 1aca9b81eb0a04eef5cedf6c48ab91da26e96967 (patch) | |
tree | 7e02261e603a36d3eb48bf570b71583ae105cd2b /gcc | |
parent | 11cb1475c8145251e113c2274bbc80b17538f5d4 (diff) | |
download | gcc-1aca9b81eb0a04eef5cedf6c48ab91da26e96967.zip gcc-1aca9b81eb0a04eef5cedf6c48ab91da26e96967.tar.gz gcc-1aca9b81eb0a04eef5cedf6c48ab91da26e96967.tar.bz2 |
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
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/java/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/java/check-init.c | 18 |
2 files changed, 19 insertions, 5 deletions
diff --git a/gcc/java/ChangeLog b/gcc/java/ChangeLog index 08cc7f1..aa5a8df 100644 --- a/gcc/java/ChangeLog +++ b/gcc/java/ChangeLog @@ -1,3 +1,9 @@ +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> * java-tree.h: Fixed typo. diff --git a/gcc/java/check-init.c b/gcc/java/check-init.c index dfc355e..bc73ab2 100644 --- a/gcc/java/check-init.c +++ b/gcc/java/check-init.c @@ -196,7 +196,7 @@ final_assign_error (name) tree name; { 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)); } @@ -791,10 +791,6 @@ check_init (exp, before) case FIX_TRUNC_EXPR: case INDIRECT_REF: case ADDR_EXPR: - case PREDECREMENT_EXPR: - case PREINCREMENT_EXPR: - case POSTDECREMENT_EXPR: - case POSTINCREMENT_EXPR: case NON_LVALUE_EXPR: case INSTANCEOF_EXPR: case FIX_CEIL_EXPR: @@ -806,6 +802,18 @@ check_init (exp, before) exp = TREE_OPERAND (exp, 0); 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: if (IS_INIT_CHECKED (exp)) return; |