diff options
author | Ranjit Mathew <rmathew@hotmail.com> | 2004-05-29 05:11:41 +0000 |
---|---|---|
committer | Ranjit Mathew <rmathew@gcc.gnu.org> | 2004-05-29 05:11:41 +0000 |
commit | edf74484b2277d89da3d02da5ed694fd6fb0716f (patch) | |
tree | fa7c6c430b62609bd2e6979cf8f506515595ec7f /gcc/java/check-init.c | |
parent | 27e1a8d2eebf19730394a178567c775dd39ac248 (diff) | |
download | gcc-edf74484b2277d89da3d02da5ed694fd6fb0716f.zip gcc-edf74484b2277d89da3d02da5ed694fd6fb0716f.tar.gz gcc-edf74484b2277d89da3d02da5ed694fd6fb0716f.tar.bz2 |
java-tree.h (DECL_LOCAL_FINAL_IUD): New macro to test if a local variable was initialised upon declaration.
* java-tree.h (DECL_LOCAL_FINAL_IUD): New macro to test if a
local variable was initialised upon declaration.
* parse.y (declare_local_variables): Set DECL_LOCAL_FINAL_IUD if
variable was final and initialised upon declaration.
* check-init.c (check_final_reassigned): Give error only if a blank
final is not definitely unassigned or if an initialised final is
reassigned.
(check_bool_init): Respect JLS2 16.1.7 requirements for boolean
assignment expressions. Remove case MODIFY_EXPR, label do_default.
(check_init): Perform initialised-variable-removing-optimisation
only on non-final local variables.
Co-Authored-By: Per Bothner <per@bothner.com>
From-SVN: r82416
Diffstat (limited to 'gcc/java/check-init.c')
-rw-r--r-- | gcc/java/check-init.c | 27 |
1 files changed, 4 insertions, 23 deletions
diff --git a/gcc/java/check-init.c b/gcc/java/check-init.c index a708dcc..3ec8d64 100644 --- a/gcc/java/check-init.c +++ b/gcc/java/check-init.c @@ -210,7 +210,8 @@ check_final_reassigned (tree decl, words before) assigned must be reported as errors */ if (DECL_FINAL (decl) && index != -2 && (index < loop_current_locals /* I.e. -1, or outside current loop. */ - || ! UNASSIGNED_P (before, index))) + || (DECL_LOCAL_FINAL_IUD (decl) ? ASSIGNED_P (before, index) + : ! UNASSIGNED_P (before, index)))) { final_assign_error (DECL_NAME (decl)); } @@ -337,27 +338,6 @@ check_bool_init (tree exp, words before, words when_false, words when_true) case TRUTH_NOT_EXPR: check_bool_init (TREE_OPERAND (exp, 0), before, when_true, when_false); return; - case MODIFY_EXPR: - { - tree tmp = TREE_OPERAND (exp, 0); - if ((tmp = get_variable_decl (tmp)) != NULL_TREE) - { - int index; - check_bool_init (TREE_OPERAND (exp, 1), before, - when_false, when_true); - check_final_reassigned (tmp, before); - index = DECL_BIT_INDEX (tmp); - if (index >= 0) - { - SET_ASSIGNED (when_false, index); - SET_ASSIGNED (when_true, index); - CLEAR_UNASSIGNED (when_false, index); - CLEAR_UNASSIGNED (when_true, index); - } - break; - } - } - goto do_default; case BIT_AND_EXPR: case BIT_IOR_EXPR: @@ -390,8 +370,8 @@ check_bool_init (tree exp, words before, words when_false, words when_true) COPY (when_true, before); } break; + default: - do_default: check_init (exp, before); COPY (when_false, before); COPY (when_true, before); @@ -531,6 +511,7 @@ check_init (tree exp, words before) definitely assigned when once we checked the whole function. */ if (! STATIC_CLASS_INIT_OPT_P () /* FIXME */ + && ! DECL_FINAL (tmp) && index >= start_current_locals && index == num_current_locals - 1) { |