From a78e4fa7643f1264968e86476a2f39a2a241f202 Mon Sep 17 00:00:00 2001 From: Jeff Sturm Date: Tue, 18 Nov 2003 03:42:30 +0000 Subject: [PATCH] re PR java/12739 (gcj emits dead bytecode) Fix PR java/12739. * java-tree.h (BLOCK_EMPTY_P): Define. * parse.y (java_complete_lhs): Check for empty blocks in TRY_FINALLY_EXPR case. From-SVN: r73690 --- gcc/java/ChangeLog | 9 ++++++++- gcc/java/java-tree.h | 2 ++ gcc/java/parse.y | 8 ++++++-- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/gcc/java/ChangeLog b/gcc/java/ChangeLog index 301a4a77371..995b21a2f3d 100644 --- a/gcc/java/ChangeLog +++ b/gcc/java/ChangeLog @@ -1,4 +1,11 @@ -2003-09-12 Andrew Haley +2003-11-17 Jeff Sturm + + Fix PR java/12739. + * java-tree.h (BLOCK_EMPTY_P): Define. + * parse.y (java_complete_lhs): Check for empty blocks + in TRY_FINALLY_EXPR case. + +2003-11-17 Andrew Haley * java-tree.h (LOCAL_VAR_OUT_OF_SCOPE_P): New. (struct lang_decl_var:freed): New variable. diff --git a/gcc/java/java-tree.h b/gcc/java/java-tree.h index 8c58bb70f8c..eb0db483963 100644 --- a/gcc/java/java-tree.h +++ b/gcc/java/java-tree.h @@ -1731,6 +1731,8 @@ while (0) #define BLOCK_EXPR_BODY(NODE) BLOCK_SUBBLOCKS(NODE) /* True for an implicit block surrounding declaration not at start of {...}. */ #define BLOCK_IS_IMPLICIT(NODE) TREE_LANG_FLAG_1 (NODE) +#define BLOCK_EMPTY_P(NODE) \ + (TREE_CODE (NODE) == BLOCK && BLOCK_EXPR_BODY (NODE) == empty_stmt_node) #define BUILD_MONITOR_ENTER(WHERE, ARG) \ { \ diff --git a/gcc/java/parse.y b/gcc/java/parse.y index 8a13e51b175..375e7ec8266 100644 --- a/gcc/java/parse.y +++ b/gcc/java/parse.y @@ -11719,9 +11719,13 @@ java_complete_lhs (tree node) case TRY_FINALLY_EXPR: COMPLETE_CHECK_OP_0 (node); COMPLETE_CHECK_OP_1 (node); - if (TREE_OPERAND (node, 0) == empty_stmt_node) + /* Reduce try/finally nodes with an empty try block. */ + if (TREE_OPERAND (node, 0) == empty_stmt_node + || BLOCK_EMPTY_P (TREE_OPERAND (node, 0))) return TREE_OPERAND (node, 1); - if (TREE_OPERAND (node, 1) == empty_stmt_node) + /* Likewise for an empty finally block. */ + if (TREE_OPERAND (node, 1) == empty_stmt_node + || BLOCK_EMPTY_P (TREE_OPERAND (node, 1))) return TREE_OPERAND (node, 0); CAN_COMPLETE_NORMALLY (node) = (CAN_COMPLETE_NORMALLY (TREE_OPERAND (node, 0))