This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Patch: Fix for PR java/2216

Tom Tromey writes:

> This might not be the best fix.  I don't understand what we are
> looking for when we decide not to emit the `goto'.  I also don't know
> when try_block is a BLOCK and when it is a TRY_EXPR.

try_block should always be a TRY_EXPR, which is made of a tried block
and a list of catch clauses. If we want to check what's in the try
clause, we need to get the 0th TREE_OPERAND of the ill named
try_block. The check for a BLOCK was most likely added without much
thinking when the tree checker was turned on, as it was suggested by
the use of BLOCK_EXPR_BODY.

> Ok to commit?  If not, any hints for how to improve the patch?

BLOCK_EXPR_BODY (try_block) happens to be (because of the use of union
in tree nodes) TREE_OPERAND (try_block, 1) which is the first catch
clause of your try/catch sequence. 

The BLOCK_EXPR_BODY was added in an attempt to optimize empty try
statement. I installed this rather vain optimization a year ago, and I
obviously didn't do a good job a it:

How about this? It seems to fix the problem you filed. Sorry for not
noticing earlier that this was my fault.

Index: jcf-write.c
RCS file: /cvs/gcc/gcc/gcc/java/jcf-write.c,v
retrieving revision 1.72
diff -u -p -r1.72 jcf-write.c
--- jcf-write.c 2001/02/04 22:44:03     1.72
+++ jcf-write.c 2001/03/13 00:25:08
@@ -2372,8 +2372,8 @@ generate_bytecode_insns (exp, target, st

        if (CAN_COMPLETE_NORMALLY (try_block)
-           && TREE_CODE (try_block) == BLOCK
-           && BLOCK_EXPR_BODY (try_block) != empty_stmt_node)
+           && (BLOCK_EXPR_BODY (TREE_OPERAND (try_block, 0))
+               != empty_stmt_node))
          emit_goto (finished_label, state);

        /* Handle exceptions. */


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]