[gcjx] Patch: FYI: emit return for void methods

Tom Tromey tromey@redhat.com
Sun Mar 27 05:02:00 GMT 2005


I'm checking this in on the gcjx branch.

We now emit an explicit RETURN_EXPR for a void method whose body can
complete normally.

Tom

Index: ChangeLog
from  Tom Tromey  <tromey@redhat.com>
	* tree.cc (visit_method): Emit explicit 'return' for void
	methods.

Index: tree.cc
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/Attic/tree.cc,v
retrieving revision 1.1.2.35
diff -u -r1.1.2.35 tree.cc
--- tree.cc 27 Mar 2005 03:08:37 -0000 1.1.2.35
+++ tree.cc 27 Mar 2005 03:09:00 -0000
@@ -132,6 +132,13 @@
 
       block->visit (this);
       tsi_link_after (&out, current, TSI_CONTINUE_LINKING);
+
+      // Emit an explicit 'return' for GCC's sake.
+      if (meth->get_return_type () == primitive_void_type
+	  && block->can_complete_normally ())
+	tsi_link_after (&out, build1 (RETURN_EXPR, void_type_node, NULL_TREE),
+			TSI_CONTINUE_LINKING);
+
       current = statements;
 
       // Handle synchronized methods.  This isn't done for JNI



More information about the Java-patches mailing list