This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

[PATCH] Java: <clinit> yanking fix.


We've been a little bit too aggressive in our way of yanking <clinit>
if it wasn't absolutely necessary. This patch fixes this problem.

./A

2000-09-29  Alexandre Petit-Bianco  <apbianco@cygnus.com>

        * parse.y (maybe_yank_clinit): Also keep <clinit> if its body
        contains something else than MODIFY_EXPR.

Index: parse.y
===================================================================
RCS file: /cvs/gcc/egcs/gcc/java/parse.y,v
retrieving revision 1.210
diff -u -p -r1.210 parse.y
--- parse.y	2000/09/23 17:09:39	1.210
+++ parse.y	2000/09/29 20:07:47
@@ -7599,6 +7599,7 @@ maybe_yank_clinit (mdecl)
 {
   tree type, current;
   tree fbody, bbody;
+  int found = 0;
   
   if (!DECL_CLINIT_P (mdecl))
     return 0;
@@ -7646,7 +7647,35 @@ maybe_yank_clinit (mdecl)
 	break;
     }
 
-  if (current)
+  /* Now we analyze the method body and look for something that
+     isn't a MODIFY_EXPR */
+  if (bbody == empty_stmt_node)
+    bbody = NULL_TREE;
+  while (bbody)
+    switch (TREE_CODE (bbody))
+      {
+      case BLOCK:
+	bbody = BLOCK_EXPR_BODY (bbody);
+	break;
+	
+      case EXPR_WITH_FILE_LOCATION:
+	bbody = EXPR_WFL_NODE (bbody);
+	break;
+	
+      case COMPOUND_EXPR:
+	bbody = TREE_OPERAND (bbody, 0);
+	break;
+	
+      case MODIFY_EXPR:
+	bbody = NULL_TREE;
+	break;
+
+      default:
+	bbody = NULL_TREE;
+	found = 1;
+      }
+
+  if (current || found)
     return 0;
 
   /* Get rid of <clinit> in the class' list of methods */

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]