This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
[gcjx] Patch: FYI: handle switches properly
- From: Tom Tromey <tromey at redhat dot com>
- To: Java Patch List <java-patches at gcc dot gnu dot org>
- Date: 23 Mar 2005 19:28:05 -0700
- Subject: [gcjx] Patch: FYI: handle switches properly
- Reply-to: tromey at redhat dot com
I'm checking this in on the gcjx branch.
This updates switch and switch block handling to be more correct.
Now we don't crash when processing a switch.
This is the last of the current round of saved-up patches.
Tom
Index: ChangeLog
from Tom Tromey <tromey@redhat.com>
* tree.cc (visit_switch_block): Annotate case exprs. Link label
into statement stream.
(visit_switch): Create label for end of 'switch'.
Index: tree.cc
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/Attic/tree.cc,v
retrieving revision 1.1.2.20
diff -u -r1.1.2.20 tree.cc
--- tree.cc 24 Mar 2005 02:29:29 -0000 1.1.2.20
+++ tree.cc 24 Mar 2005 02:30:11 -0000
@@ -704,6 +704,10 @@
expr->visit (this);
tree expr_tree = current;
+ tree done = build0 (LABEL_DECL, NULL_TREE);
+ DECL_CONTEXT (done) = current_block;
+ target_map[swstmt] = std::make_pair (NULL_TREE, done);
+
tree body_tree = alloc_stmt_list ();
tree_stmt_iterator out = tsi_start (body_tree);
@@ -722,6 +726,13 @@
current = build3 (SWITCH_EXPR, NULL_TREE, expr_tree, body_tree, NULL_TREE);
annotate (current, swstmt);
+
+ body_tree = alloc_stmt_list ();
+ out = tsi_start (body_tree);
+ tsi_link_after (&out, current, TSI_CONTINUE_LINKING);
+ tsi_link_after (&out, build1 (LABEL_EXPR, void_type_node, done),
+ TSI_CONTINUE_LINKING);
+ current = body_tree;
}
void
@@ -736,6 +747,7 @@
tree body_tree = alloc_stmt_list ();
tree_stmt_iterator out = tsi_start (body_tree);
+ // Multiple switch labels point at the same label in the code.
tree label = build0 (LABEL_DECL, NULL_TREE);
DECL_CONTEXT (label) = current_block;
@@ -748,9 +760,12 @@
tree new_label = build3 (CASE_LABEL_EXPR,
void_type_node,
build_int (value), NULL_TREE, label);
+ annotate (new_label, swblock);
tsi_link_after (&out, new_label, TSI_CONTINUE_LINKING);
}
+ tsi_link_after (&out, build1 (LABEL_EXPR, void_type_node, label),
+ TSI_CONTINUE_LINKING);
tree stmt_tree = transform_list (statements);
tsi_link_after (&out, stmt_tree, TSI_CONTINUE_LINKING);