re PR java/11533 (Inlining drops static initialization of inner class)
authorAndrew Haley <aph@redhat.com>
Wed, 12 Nov 2003 15:24:42 +0000 (15:24 +0000)
committerAndrew Haley <aph@gcc.gnu.org>
Wed, 12 Nov 2003 15:24:42 +0000 (15:24 +0000)
2003-11-12  Andrew Haley  <aph@redhat.com>

        PR java/11533
        * lang.c (merge_init_test_initialization): Clear DECL_INITIAL for
        init_test_decls being inlined.

        PR java/12890:
        * parse.y (do_resolve_class): Check return value from
        breakdown_qualified().

From-SVN: r73494

gcc/java/ChangeLog
gcc/java/lang.c
gcc/java/parse.y

index e999ddb859901377f4ab447a6a277ad5b5a55c04..303e71cd259485d3e06f38943cee519866bb4224 100644 (file)
@@ -1,3 +1,13 @@
+2003-11-12  Andrew Haley  <aph@redhat.com>
+
+       PR java/11533
+       * lang.c (merge_init_test_initialization): Clear DECL_INITIAL for
+       init_test_decls being inlined.
+
+       PR java/12890:
+       * parse.y (do_resolve_class): Check return value from
+       breakdown_qualified().
+
 2003-11-11  Tom Tromey  <tromey@redhat.com>
 
        PR java/12915:
index 615d250c0187c1722f59ff2f813fd7419e98c44e..a649a4ad0f9ea7c59dd37bfb16bc3bc284c02f33 100644 (file)
@@ -926,6 +926,24 @@ merge_init_test_initialization (void **entry, void *x)
   if (!*init_test_decl)
     *init_test_decl = (tree)n->value;
 
+  /* This fixes a weird case.  
+
+  The front end assumes that once we have called a method that
+  initializes some class, we can assume the class is initialized.  It
+  does this by setting the DECL_INITIAL of the init_test_decl for that
+  class, and no initializations are emitted for that class.
+  
+  However, what if the method that is suppoed to do the initialization
+  is itself inlined in the caller?  When expanding the called method
+  we'll assume that the class initalization has already been done,
+  because the DECL_INITIAL of the init_test_decl is set.
+  
+  To fix this we remove the DECL_INITIAL (in the caller scope) of all
+  the init_test_decls corresponding to classes initialized by the
+  inlined method.  This makes the caller no longer assume that the
+  method being inlined does any class initializations.  */
+  DECL_INITIAL (*init_test_decl) = NULL;
+
   return true;
 }
 
index fc4963d3fbf1f88978225a02598ff6e65a53a5c1..c1b70ddc51d8ae0197d89d0fa7ebaa7efd7a060d 100644 (file)
@@ -5718,14 +5718,16 @@ do_resolve_class (tree enclosing, tree class_type, tree decl, tree cl)
         class and then treat Id as a member type.  If we can't find Q
         as a class then we fall through.  */
       tree q, left, left_type, right;
-      breakdown_qualified (&left, &right, TYPE_NAME (class_type));
-      BUILD_PTR_FROM_NAME (left_type, left);
-      q = do_resolve_class (enclosing, left_type, decl, cl);
-      if (q)
+      if (breakdown_qualified (&left, &right, TYPE_NAME (class_type)) == 0)
        {
-         enclosing = q;
-         saved_enclosing_type = TREE_TYPE (q);
-         BUILD_PTR_FROM_NAME (class_type, right);
+         BUILD_PTR_FROM_NAME (left_type, left);
+         q = do_resolve_class (enclosing, left_type, decl, cl);
+         if (q)
+           {
+             enclosing = q;
+             saved_enclosing_type = TREE_TYPE (q);
+             BUILD_PTR_FROM_NAME (class_type, right);
+           }
        }
     }
 
@@ -16218,8 +16220,8 @@ attach_init_test_initialization_flags (void **entry, void *ptr)
   return true;
 }
 
-/* This function is called for each classes that is known definitely
-   assigned when a given static method was called. This function
+/* This function is called for each class that is known definitely
+   initialized when a given static method was called. This function
    augments a compound expression (INFO) storing all assignment to
    initialized static class flags if a flag already existed, otherwise
    a new one is created.  */