diff options
author | Alexandre Petit-Bianco <apbianco@gcc.gnu.org> | 2000-03-13 21:01:05 -0800 |
---|---|---|
committer | Alexandre Petit-Bianco <apbianco@gcc.gnu.org> | 2000-03-13 21:01:05 -0800 |
commit | c2952b018a1baf25b12c339f2b96518425164295 (patch) | |
tree | bf1619873e76c17441a1423f1eaba6a4a64f054a /gcc/java/check-init.c | |
parent | e4476d1cbd567593c068dba421b5e089f7ccbcd5 (diff) | |
download | gcc-c2952b018a1baf25b12c339f2b96518425164295.zip gcc-c2952b018a1baf25b12c339f2b96518425164295.tar.gz gcc-c2952b018a1baf25b12c339f2b96518425164295.tar.bz2 |
Added Java 1.1 language features.
From-SVN: r32517
Diffstat (limited to 'gcc/java/check-init.c')
-rw-r--r-- | gcc/java/check-init.c | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/gcc/java/check-init.c b/gcc/java/check-init.c index 36a0f19..aa0e47b 100644 --- a/gcc/java/check-init.c +++ b/gcc/java/check-init.c @@ -374,13 +374,9 @@ check_init (exp, before) int index = DECL_BIT_INDEX (exp); if (index >= 0 && ! SET_P (before, index)) { -#if 1 - parse_error_context (wfl, - "Variable `%s' may not have been initialized" - , IDENTIFIER_POINTER (DECL_NAME (exp))); -#else - error_with_decl (exp, "variable may be used uninitialized"); -#endif + parse_error_context + (wfl, "Variable `%s' may not have been initialized", + IDENTIFIER_POINTER (DECL_NAME (exp))); /* Suppress further errors. */ DECL_BIT_INDEX (exp) = -1; } @@ -388,11 +384,20 @@ check_init (exp, before) break; case MODIFY_EXPR: tmp = TREE_OPERAND (exp, 0); - if (TREE_CODE (tmp) == VAR_DECL && ! FIELD_STATIC (tmp)) + /* We're interested in variable declaration and parameter + declaration when they're declared with the `final' modifier. */ + if ((TREE_CODE (tmp) == VAR_DECL && ! FIELD_STATIC (tmp)) + || (TREE_CODE (tmp) == PARM_DECL && LOCAL_FINAL (tmp))) { int index; check_init (TREE_OPERAND (exp, 1), before); index = DECL_BIT_INDEX (tmp); + /* A final local already assigned or a final parameter + assigned must be reported as errors */ + if (LOCAL_FINAL (tmp) + && (index == -1 || TREE_CODE (tmp) == PARM_DECL)) + parse_error_context (wfl, "Can't assign here a value to the `final' variable `%s'", IDENTIFIER_POINTER (DECL_NAME (tmp))); + if (index >= 0) SET_BIT (before, index); /* Minor optimization. See comment for start_current_locals. */ |