parse.y (maybe_yank_clinit): Also keep <clinit> if its body contains something else...
authorAlexandre Petit-Bianco <apbianco@cygnus.com>
Fri, 29 Sep 2000 20:14:53 +0000 (20:14 +0000)
committerAlexandre Petit-Bianco <apbianco@gcc.gnu.org>
Fri, 29 Sep 2000 20:14:53 +0000 (13:14 -0700)
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.

(http://gcc.gnu.org/ml/gcc-patches/2000-09/msg01141.html)

From-SVN: r36670

gcc/java/ChangeLog
gcc/java/parse.y

index 83c5648..632707b 100644 (file)
@@ -1,3 +1,8 @@
+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.
+
 2000-09-23  Mark Mitchell  <mark@codesourcery.com>
 
        * Make-lang.in (JAVA_SRCS): Include java-tree.h.
index b1a8e15..e6aeb32 100644 (file)
@@ -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 */