java/11533: Inlining drops static initialization of inner class

Andrew Haley aph@redhat.com
Tue Nov 11 20:30:00 GMT 2003


Fixes a nasty inliner bug.

Andrew.


2003-11-11  Andrew Haley  <aph@redhat.com>

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

Index: lang.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/lang.c,v
retrieving revision 1.145
diff -c -2 -p -r1.145 lang.c
*** lang.c	24 Oct 2003 09:29:40 -0000	1.145
--- lang.c	11 Nov 2003 20:11:57 -0000
*************** merge_init_test_initialization (void **e
*** 927,930 ****
--- 927,948 ----
      *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, so 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;
  }



More information about the Java-patches mailing list