From 7304c6cfe91d479beeb49167441faa26226cf8cf Mon Sep 17 00:00:00 2001 From: Andrew Haley Date: Wed, 12 Nov 2003 15:24:42 +0000 Subject: re PR java/11533 (Inlining drops static initialization of inner class) 2003-11-12 Andrew Haley 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 | 10 ++++++++++ gcc/java/lang.c | 18 ++++++++++++++++++ gcc/java/parse.y | 20 +++++++++++--------- 3 files changed, 39 insertions(+), 9 deletions(-) (limited to 'gcc') diff --git a/gcc/java/ChangeLog b/gcc/java/ChangeLog index e999ddb..303e71c 100644 --- a/gcc/java/ChangeLog +++ b/gcc/java/ChangeLog @@ -1,3 +1,13 @@ +2003-11-12 Andrew Haley + + 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 PR java/12915: diff --git a/gcc/java/lang.c b/gcc/java/lang.c index 615d250..a649a4a 100644 --- a/gcc/java/lang.c +++ b/gcc/java/lang.c @@ -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; } diff --git a/gcc/java/parse.y b/gcc/java/parse.y index fc4963d..c1b70dd 100644 --- a/gcc/java/parse.y +++ b/gcc/java/parse.y @@ -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. */ -- cgit v1.1