diff options
author | tromey <tromey@138bc75d-0d04-0410-961f-82ee72b054a4> | 2002-05-07 03:32:01 +0000 |
---|---|---|
committer | tromey <tromey@138bc75d-0d04-0410-961f-82ee72b054a4> | 2002-05-07 03:32:01 +0000 |
commit | bae6ff29e0cef3c7b5f1580de2d286d2bdae6d61 (patch) | |
tree | 7159ea0ab41b06803b073585f69939e4604b03d4 /gcc/java | |
parent | 8d91268d34eb130ea8bf6080b7e9ff109b8871db (diff) | |
download | gcc-bae6ff29e0cef3c7b5f1580de2d286d2bdae6d61.tar.gz |
Fix for PR java/5941:
* parse.y (finish_for_loop): Set SUPPRESS_UNREACHABLE_ERROR for
loop update expression.
(java_complete_lhs): Use SUPPRESS_UNREACHABLE_ERROR.
* java-tree.h (SUPPRESS_UNREACHABLE_ERROR): New macro.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@53247 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/java')
-rw-r--r-- | gcc/java/ChangeLog | 8 | ||||
-rw-r--r-- | gcc/java/java-tree.h | 7 | ||||
-rw-r--r-- | gcc/java/parse.y | 29 |
3 files changed, 42 insertions, 2 deletions
diff --git a/gcc/java/ChangeLog b/gcc/java/ChangeLog index a4b7a38ebdd..6f74998ea56 100644 --- a/gcc/java/ChangeLog +++ b/gcc/java/ChangeLog @@ -1,3 +1,11 @@ +2002-05-06 Tom Tromey <tromey@redhat.com> + + Fix for PR java/5941: + * parse.y (finish_for_loop): Set SUPPRESS_UNREACHABLE_ERROR for + loop update expression. + (java_complete_lhs): Use SUPPRESS_UNREACHABLE_ERROR. + * java-tree.h (SUPPRESS_UNREACHABLE_ERROR): New macro. + 2002-05-04 Mark Wielaard <mark@klomp.org> For PR java/6519: diff --git a/gcc/java/java-tree.h b/gcc/java/java-tree.h index f591b5fe33f..e0dbe48830c 100644 --- a/gcc/java/java-tree.h +++ b/gcc/java/java-tree.h @@ -43,6 +43,7 @@ struct JCF; 0: IS_A_SINGLE_IMPORT_CLASSFILE_NAME_P (in IDENTIFIER_NODE) RESOLVE_EXPRESSION_NAME_P (in EXPR_WITH_FILE_LOCATION) FOR_LOOP_P (in LOOP_EXPR) + SUPPRESS_UNREACHABLE_ERROR (for other _EXPR nodes) ANONYMOUS_CLASS_P (in RECORD_TYPE) ARG_FINAL_P (in TREE_LIST) 1: CLASS_HAS_SUPER_FLAG (in TREE_VEC). @@ -1503,6 +1504,12 @@ extern tree *type_map; declared with the final modifier */ #define ARG_FINAL_P(NODE) TREE_LANG_FLAG_0 (NODE) +/* True if NODE (some kind of EXPR, but not a WFL) should not give an + error if it is found to be unreachable. This can only be applied + to those EXPRs which can be used as the update expression of a + `for' loop. In particular it can't be set on a LOOP_EXPR. */ +#define SUPPRESS_UNREACHABLE_ERROR(NODE) TREE_LANG_FLAG_0 (NODE) + /* True if EXPR (a WFL in that case) resolves into a package name */ #define RESOLVE_PACKAGE_NAME_P(WFL) TREE_LANG_FLAG_3 (WFL) diff --git a/gcc/java/parse.y b/gcc/java/parse.y index c45ff1ecae8..526850dffc4 100644 --- a/gcc/java/parse.y +++ b/gcc/java/parse.y @@ -11842,7 +11842,17 @@ java_complete_lhs (node) if (TREE_CODE (nn) != EXIT_EXPR) { SET_WFL_OPERATOR (wfl_operator, node, wfl_op2); - parse_error_context (wfl_operator, "Unreachable statement"); + if (SUPPRESS_UNREACHABLE_ERROR (nn)) + { + /* Perhaps this warning should have an + associated flag. The code being compiled is + pedantically correct, but useless. */ + parse_warning_context (wfl_operator, + "Unreachable statement"); + } + else + parse_error_context (wfl_operator, + "Unreachable statement"); } } TREE_OPERAND (node, 1) = java_complete_tree (TREE_OPERAND (node, 1)); @@ -14981,7 +14991,22 @@ finish_for_loop (location, condition, update, body) /* Put the condition and the loop body in place */ tree loop = finish_loop_body (location, condition, body, 0); /* LOOP is the current loop which has been now popped of the loop - stack. Install the update block */ + stack. Mark the update block as reachable and install it. We do + this because the (current interpretation of the) JLS requires + that the update expression be considered reachable even if the + for loop's body doesn't complete normally. */ + if (update != NULL_TREE && update != empty_stmt_node) + { + tree up2 = update; + if (TREE_CODE (up2) == EXPR_WITH_FILE_LOCATION) + up2 = EXPR_WFL_NODE (up2); + /* Try to detect constraint violations. These would be + programming errors somewhere. */ + if (! IS_EXPR_CODE_CLASS (TREE_CODE_CLASS (TREE_CODE (up2))) + | TREE_CODE (up2) == LOOP_EXPR) + abort (); + SUPPRESS_UNREACHABLE_ERROR (up2) = 1; + } LOOP_EXPR_BODY_UPDATE_BLOCK (LOOP_EXPR_BODY (loop)) = update; return loop; } |