OSDN Git Service

For PR java/4509:
authortromey <tromey@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 21 Dec 2001 05:28:27 +0000 (05:28 +0000)
committertromey <tromey@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 21 Dec 2001 05:28:27 +0000 (05:28 +0000)
* parse.y (java_complete_lhs) [COMPOUND_EXPR]: Correctly compute
CAN_COMPLETE_NORMALLY for the node.
* jcf-write.c (generate_bytecode_insns) [COMPOUND_EXPR]: Don't
generate code for second branch if first branch can't complete
normally.
(generate_bytecode_insns) [LOOP_EXPR]: Don't generate `goto' to
the loop head if the loop body can't complete normally.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@48233 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/java/ChangeLog
gcc/java/jcf-write.c
gcc/java/parse.y

index 1104546..09507d2 100644 (file)
@@ -1,5 +1,16 @@
 2001-12-20  Tom Tromey  <tromey@redhat.com>
 
+       For PR java/4509:
+       * parse.y (java_complete_lhs) [COMPOUND_EXPR]: Correctly compute
+       CAN_COMPLETE_NORMALLY for the node.
+       * jcf-write.c (generate_bytecode_insns) [COMPOUND_EXPR]: Don't
+       generate code for second branch if first branch can't complete
+       normally.
+       (generate_bytecode_insns) [LOOP_EXPR]: Don't generate `goto' to
+       the loop head if the loop body can't complete normally.
+
+2001-12-20  Tom Tromey  <tromey@redhat.com>
+
        For PR java/4766:
        * jcf-write.c (generate_bytecode_insns) [TRY_FINALLY_EXPR]: Handle
        case where `finally' clause can't complete normally.
index f6c0bfa..334465e 100644 (file)
@@ -1483,7 +1483,11 @@ generate_bytecode_insns (exp, target, state)
       break;
     case COMPOUND_EXPR:        
       generate_bytecode_insns (TREE_OPERAND (exp, 0), IGNORE_TARGET, state);
-      generate_bytecode_insns (TREE_OPERAND (exp, 1), target, state);
+      /* Normally the first operand to a COMPOUND_EXPR must complete
+        normally.  However, in the special case of a do-while
+        statement this is not necessarily the case.  */
+      if (CAN_COMPLETE_NORMALLY (TREE_OPERAND (exp, 0)))
+       generate_bytecode_insns (TREE_OPERAND (exp, 1), target, state);
       break;
     case EXPR_WITH_FILE_LOCATION:
       {
@@ -1880,7 +1884,8 @@ generate_bytecode_insns (exp, target, state)
          {
            struct jcf_block *head_label = get_jcf_label_here (state);
            generate_bytecode_insns (body, IGNORE_TARGET, state);
-           emit_goto (head_label, state);
+           if (CAN_COMPLETE_NORMALLY (body))
+             emit_goto (head_label, state);
          }
       }
       break;
index aeec759..7c50c97 100644 (file)
@@ -11776,8 +11776,12 @@ java_complete_lhs (node)
          TREE_OPERAND (node, 1) = java_complete_tree (TREE_OPERAND (node, 1));
          if (TREE_OPERAND (node, 1) == error_mark_node)
            return error_mark_node;
+         /* Even though we might allow the case where the first
+            operand doesn't return normally, we still should compute
+            CAN_COMPLETE_NORMALLY correctly.  */
          CAN_COMPLETE_NORMALLY (node)
-           = CAN_COMPLETE_NORMALLY (TREE_OPERAND (node, 1));
+           = (CAN_COMPLETE_NORMALLY (TREE_OPERAND (node, 0))
+              && CAN_COMPLETE_NORMALLY (TREE_OPERAND (node, 1)));
        }
       TREE_TYPE (node) = TREE_TYPE (TREE_OPERAND (node, 1));
       break;