This is the mail archive of the
mailing list for the GCC project.
java/11533: Inlining drops static initialization of inner class
- From: Andrew Haley <aph at redhat dot com>
- To: GCC libjava patches <java-patches at gcc dot gnu dot org>, Gcc Patch List <gcc-patches at gcc dot gnu dot org>
- Date: Tue, 11 Nov 2003 20:29:34 +0000
- Subject: java/11533: Inlining drops static initialization of inner class
Fixes a nasty inliner bug.
2003-11-11 Andrew Haley <email@example.com>
* lang.c (merge_init_test_initialization): Clear DECL_INITIAL for
init_test_decls being inlined.
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;