summaryrefslogtreecommitdiff
path: root/gcc/java/parse.y
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/java/parse.y')
-rw-r--r--gcc/java/parse.y29
1 files changed, 27 insertions, 2 deletions
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;
}