[PATCH] java/12739: Reduce try/finally expr with empty blocks
Jeff Sturm
jsturm@one-point.com
Mon Oct 27 18:09:00 GMT 2003
Fixes slight regression caused by my unit-at-a-time patches. The parser
used to substitute empty BLOCK nodes with an empty_stmt_node, but it was
awkward handling these in places that expected a BLOCK node.
Tested by rebuilding libjava and running testsuite. OK for mainline?
Jeff
2003-10-26 Jeff Sturm <jsturm@one-point.com>
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.
Index: java-tree.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/java-tree.h,v
retrieving revision 1.186
diff -u -p -r1.186 java-tree.h
--- java-tree.h 24 Oct 2003 09:29:40 -0000 1.186
+++ java-tree.h 27 Oct 2003 17:41:01 -0000
@@ -1727,6 +1727,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) \
{ \
Index: parse.y
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/parse.y,v
retrieving revision 1.451
diff -u -p -r1.451 parse.y
--- parse.y 22 Oct 2003 18:06:38 -0000 1.451
+++ parse.y 27 Oct 2003 17:41:05 -0000
@@ -11720,9 +11720,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))
More information about the Gcc-patches
mailing list