This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: Patch: don't generate dead bytecode
- To: Per Bothner <per at bothner dot com>
- Subject: Re: Patch: don't generate dead bytecode
- From: Per Bothner <per at bothner dot com>
- Date: Tue, 09 Oct 2001 17:40:43 -0700
- CC: tromey at redhat dot com, Gcc Patch List <gcc-patches at gcc dot gnu dot org>, Java Patch List <java-patches at gcc dot gnu dot org>, Alexandre Petit-Bianco <apbianco at cygnus dot com>
- References: <87elocq19k.fsf@creche.redhat.com> <3BC39195.6040803@bothner.com>
Oops. I left out one "think" from the patch. (I've got two patches
going at once.) Try again ...
Index: parse.y
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/parse.y,v
retrieving revision 1.318
diff -u -p -r1.318 parse.y
--- parse.y 2001/10/09 05:40:35 1.318
+++ parse.y 2001/10/10 00:02:47
@@ -15008,6 +14993,9 @@ patch_if_else_statement (node)
tree node;
{
tree expression = TREE_OPERAND (node, 0);
+ int can_complete_normally
+ = (CAN_COMPLETE_NORMALLY (TREE_OPERAND (node, 1))
+ | CAN_COMPLETE_NORMALLY (TREE_OPERAND (node, 2)));
TREE_TYPE (node) = error_mark_node;
EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (node);
@@ -15023,11 +15011,22 @@ patch_if_else_statement (node)
return error_mark_node;
}
+ if (TREE_CODE (expression) == INTEGER_CST)
+ {
+ if (integer_zerop (expression))
+ node = TREE_OPERAND (node, 2);
+ else
+ node = TREE_OPERAND (node, 1);
+ if (CAN_COMPLETE_NORMALLY (node) != can_complete_normally)
+ {
+ node = build (COMPOUND_EXPR, void_type_node, node, empty_stmt_node);
+ CAN_COMPLETE_NORMALLY (node) = can_complete_normally;
+ }
+ return node;
+ }
TREE_TYPE (node) = void_type_node;
TREE_SIDE_EFFECTS (node) = 1;
- CAN_COMPLETE_NORMALLY (node)
- = CAN_COMPLETE_NORMALLY (TREE_OPERAND (node, 1))
- | CAN_COMPLETE_NORMALLY (TREE_OPERAND (node, 2));
+ CAN_COMPLETE_NORMALLY (node) = can_complete_normally;
return node;
}