This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
Re: Patch: Fix for PR java/2216
- To: tromey at redhat dot com
- Subject: Re: Patch: Fix for PR java/2216
- From: Alexandre Petit-Bianco <apbianco at cygnus dot com>
- Date: Mon, 12 Mar 2001 16:31:47 -0800 (PST)
- Cc: Gcc Patch List <gcc-patches at gcc dot gnu dot org>, Java Patch List <java-patches at gcc dot gnu dot org>
- References: <87zoeqenkv.fsf@creche.redhat.com>
- Reply-To: apbianco at cygnus dot com
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:
http://gcc.gnu.org/ml/gcc-patches/2000-02/msg00696.html
http://gcc.gnu.org/ml/gcc-patches/2000-03/msg00762.html
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. */
./A