From: Paolo Bonzini Date: Tue, 10 May 2005 13:23:35 +0000 (+0000) Subject: re PR java/21436 (imports not remembered for previously compiled files) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=27e928edee9751a937bbd0bd175f233cd4581b63;p=gcc.git re PR java/21436 (imports not remembered for previously compiled files) gcc/java: 2005-05-10 Paolo Bonzini PR java/21436 * class.c (maybe_layout_super_class): Look for imports in this_class. * parse.h (ctxp_for_generation_last): New. (do_resolve_class): Add a parameter. * parse.y (ctxp_for_generation_last): New. (java_pop_parser_context): Add at end of list. (find_in_imports, find_in_imports_on_demand): Look in ctxp if the TYPE_IMPORT_LIST or respectively the TYPE_IMPORT_DEMAND_LIST of the given type are NULL. (do_resolve_class): Look into the imports of the new second parameter. Adjust recursive calls. (resolve_class, resolve_inner_class, find_as_inner_class): Adjust calls to do_resolve_class. (create_class): Set the TYPE_IMPORT_LIST and TYPE_IMPORT_DEMAND_LIST. (java_complete_class): Do not do that here. libjava: 2005-05-10 Paolo Bonzini PR java/21436 * testsuite/libjava.jacks/jacks.xfail: Adjust. From-SVN: r99513 --- diff --git a/gcc/java/ChangeLog b/gcc/java/ChangeLog index 5b3adf8c6d7..5da68340ad3 100644 --- a/gcc/java/ChangeLog +++ b/gcc/java/ChangeLog @@ -1,3 +1,21 @@ +2005-05-10 Paolo Bonzini + + PR java/21436 + * class.c (maybe_layout_super_class): Look for imports in this_class. + * parse.h (ctxp_for_generation_last): New. + (do_resolve_class): Add a parameter. + * parse.y (ctxp_for_generation_last): New. + (java_pop_parser_context): Add at end of list. + (find_in_imports, find_in_imports_on_demand): Look in ctxp + if the TYPE_IMPORT_LIST or respectively the TYPE_IMPORT_DEMAND_LIST of + the given type are NULL. + (do_resolve_class): Look into the imports of the new second parameter. + Adjust recursive calls. + (resolve_class, resolve_inner_class, find_as_inner_class): Adjust + calls to do_resolve_class. + (create_class): Set the TYPE_IMPORT_LIST and TYPE_IMPORT_DEMAND_LIST. + (java_complete_class): Do not do that here. + 2005-05-03 Thomas Fitzsimmons PR java/20309 @@ -15447,7 +15465,7 @@ (CLASS_P): Moved around. (java_parse_abort_on_error): Macro moved from jcf-parse.c * jcf-parse.c (java_parse_abort_on_error): Macro moved to - java-parse.h + java-tree.h (jcf_parse_source): Changed leading comment. Removed unnecessary fclose and CLASS_FROM_SOURCE_P marking. (parse_source_file): New local variables remember_for_generation diff --git a/gcc/java/class.c b/gcc/java/class.c index 321c1e49554..9ab88570d03 100644 --- a/gcc/java/class.c +++ b/gcc/java/class.c @@ -2085,7 +2085,7 @@ maybe_layout_super_class (tree super_class, tree this_class) DECL_SOURCE_LINE (this_decl), 0); #endif } - super_class = do_resolve_class (NULL_TREE, /* FIXME? */ + super_class = do_resolve_class (NULL_TREE, this_class, super_class, NULL_TREE, this_wrap); if (!super_class) return NULL_TREE; /* FIXME, NULL_TREE not checked by caller. */ diff --git a/gcc/java/parse.h b/gcc/java/parse.h index 5948348895a..232eead9862 100644 --- a/gcc/java/parse.h +++ b/gcc/java/parse.h @@ -937,7 +937,7 @@ void java_layout_classes (void); void java_reorder_fields (void); tree java_method_add_stmt (tree, tree); int java_report_errors (void); -extern tree do_resolve_class (tree, tree, tree, tree); +extern tree do_resolve_class (tree, tree, tree, tree, tree); #endif char *java_get_line_col (const char *, int, int); extern void reset_report (void); @@ -960,5 +960,6 @@ extern void java_finish_classes (void); extern GTY(()) struct parser_ctxt *ctxp; extern GTY(()) struct parser_ctxt *ctxp_for_generation; +extern GTY(()) struct parser_ctxt *ctxp_for_generation_last; #endif /* ! GCC_JAVA_PARSE_H */ diff --git a/gcc/java/parse.y b/gcc/java/parse.y index 860725f11bc..b4facbba592 100644 --- a/gcc/java/parse.y +++ b/gcc/java/parse.y @@ -361,6 +361,7 @@ struct parser_ctxt *ctxp; /* List of things that were analyzed for which code will be generated */ struct parser_ctxt *ctxp_for_generation = NULL; +struct parser_ctxt *ctxp_for_generation_last = NULL; /* binop_lookup maps token to tree_code. It is used where binary operations are involved and required by the parser. RDIV_EXPR @@ -2765,8 +2766,12 @@ java_pop_parser_context (int generate) do is to just update a list of class names. */ if (generate) { - ctxp->next = ctxp_for_generation; - ctxp_for_generation = ctxp; + if (ctxp_for_generation_last == NULL) + ctxp_for_generation = ctxp; + else + ctxp_for_generation_last->next = ctxp; + ctxp->next = NULL; + ctxp_for_generation_last = ctxp; } /* And restore those of the previous context */ @@ -3706,7 +3711,7 @@ resolve_inner_class (htab_t circularity_hash, tree cl, tree *enclosing, break; if (TREE_CODE (local_super) == POINTER_TYPE) - local_super = do_resolve_class (NULL, local_super, NULL, NULL); + local_super = do_resolve_class (NULL, NULL, local_super, NULL, NULL); else local_super = TYPE_NAME (local_super); @@ -3768,7 +3773,7 @@ find_as_inner_class (tree enclosing, tree name, tree cl) acc = merge_qualified_name (acc, EXPR_WFL_NODE (TREE_PURPOSE (qual))); BUILD_PTR_FROM_NAME (ptr, acc); - decl = do_resolve_class (NULL_TREE, ptr, NULL_TREE, cl); + decl = do_resolve_class (NULL_TREE, NULL_TREE, ptr, NULL_TREE, cl); } /* A NULL qual and a decl means that the search ended @@ -4177,6 +4182,12 @@ create_class (int flags, tree id, tree super, tree interfaces) virtual function table in java.lang.object. */ TYPE_VFIELD (TREE_TYPE (decl)) = TYPE_VFIELD (object_type_node); + /* We keep the compilation unit imports in the class so that + they can be used later to resolve type dependencies that + aren't necessary to solve now. */ + TYPE_IMPORT_LIST (TREE_TYPE (decl)) = ctxp->import_list; + TYPE_IMPORT_DEMAND_LIST (TREE_TYPE (decl)) = ctxp->import_demand_list; + /* Add the private this$ field, Replicate final locals still in scope as private final fields mangled like val$. This does not occur for top level (static) inner classes. */ @@ -5683,12 +5694,6 @@ java_complete_class (void) { jdep *dep; - /* We keep the compilation unit imports in the class so that - they can be used later to resolve type dependencies that - aren't necessary to solve now. */ - TYPE_IMPORT_LIST (TREE_TYPE (cclass)) = ctxp->import_list; - TYPE_IMPORT_DEMAND_LIST (TREE_TYPE (cclass)) = ctxp->import_demand_list; - for (dep = CLASSD_FIRST (cclassd); dep; dep = JDEP_CHAIN (dep)) { tree decl; @@ -5839,7 +5844,7 @@ resolve_class (tree enclosing, tree class_type, tree decl, tree cl) WFL_STRIP_BRACKET (cl, cl); /* 2- Resolve the bare type */ - if (!(resolved_type_decl = do_resolve_class (enclosing, class_type, + if (!(resolved_type_decl = do_resolve_class (enclosing, NULL_TREE, class_type, decl, cl))) return NULL_TREE; resolved_type = TREE_TYPE (resolved_type_decl); @@ -5862,7 +5867,8 @@ resolve_class (tree enclosing, tree class_type, tree decl, tree cl) and (but it doesn't really matter) qualify_and_find. */ tree -do_resolve_class (tree enclosing, tree class_type, tree decl, tree cl) +do_resolve_class (tree enclosing, tree import_type, tree class_type, tree decl, + tree cl) { tree new_class_decl = NULL_TREE, super = NULL_TREE; tree saved_enclosing_type = enclosing ? TREE_TYPE (enclosing) : NULL_TREE; @@ -5879,7 +5885,7 @@ do_resolve_class (tree enclosing, tree class_type, tree decl, tree cl) if (split_qualified_name (&left, &right, TYPE_NAME (class_type)) == 0) { BUILD_PTR_FROM_NAME (left_type, left); - q = do_resolve_class (enclosing, left_type, decl, cl); + q = do_resolve_class (enclosing, import_type, left_type, decl, cl); if (q) { enclosing = q; @@ -5924,8 +5930,11 @@ do_resolve_class (tree enclosing, tree class_type, tree decl, tree cl) return new_class_decl; } - /* 1- Check for the type in single imports. This will change - TYPE_NAME() if something relevant is found */ + /* 1- Check for the type in single imports. Look at enclosing classes and, + if we're laying out a superclass, at the import list for the subclass. + This will change TYPE_NAME() if something relevant is found. */ + if (import_type && TYPE_IMPORT_LIST (import_type)) + find_in_imports (import_type, class_type); find_in_imports (saved_enclosing_type, class_type); /* 2- And check for the type in the current compilation unit */ @@ -5947,8 +5956,14 @@ do_resolve_class (tree enclosing, tree class_type, tree decl, tree cl) /* 4- Check the import on demands. Don't allow bar.baz to be imported from foo.* */ if (!QUALIFIED_P (TYPE_NAME (class_type))) - if (find_in_imports_on_demand (saved_enclosing_type, class_type)) - return NULL_TREE; + { + if (import_type + && TYPE_IMPORT_DEMAND_LIST (import_type) + && find_in_imports_on_demand (import_type, class_type)) + return NULL_TREE; + if (find_in_imports_on_demand (saved_enclosing_type, class_type)) + return NULL_TREE; + } /* If found in find_in_imports_on_demand, the type has already been loaded. */ @@ -6970,8 +6985,12 @@ process_imports (void) static void find_in_imports (tree enclosing_type, tree class_type) { - tree import = (enclosing_type ? TYPE_IMPORT_LIST (enclosing_type) : - ctxp->import_list); + tree import; + if (enclosing_type && TYPE_IMPORT_LIST (enclosing_type)) + import = TYPE_IMPORT_LIST (enclosing_type); + else + import = ctxp->import_list; + while (import) { if (TREE_VALUE (import) == TYPE_NAME (class_type)) @@ -7129,12 +7148,16 @@ static int find_in_imports_on_demand (tree enclosing_type, tree class_type) { tree class_type_name = TYPE_NAME (class_type); - tree import = (enclosing_type ? TYPE_IMPORT_DEMAND_LIST (enclosing_type) : - ctxp->import_demand_list); tree cl = NULL_TREE; int seen_once = -1; /* -1 when not set, 1 if seen once, >1 otherwise. */ int to_return = -1; /* -1 when not set, 0 or 1 otherwise */ tree node; + tree import; + + if (enclosing_type && TYPE_IMPORT_DEMAND_LIST (enclosing_type)) + import = TYPE_IMPORT_DEMAND_LIST (enclosing_type); + else + import = ctxp->import_demand_list; for (; import; import = TREE_CHAIN (import)) { diff --git a/libjava/ChangeLog b/libjava/ChangeLog index f4b584d793e..bbcff752642 100644 --- a/libjava/ChangeLog +++ b/libjava/ChangeLog @@ -1,3 +1,8 @@ +2005-05-10 Paolo Bonzini + + PR java/21436 + * testsuite/libjava.jacks/jacks.xfail: Adjust. + 2005-05-09 Mike Stump * configure: Regenerate. diff --git a/libjava/testsuite/libjava.jacks/jacks.xfail b/libjava/testsuite/libjava.jacks/jacks.xfail index 85d857815d1..4cc878464fd 100644 --- a/libjava/testsuite/libjava.jacks/jacks.xfail +++ b/libjava/testsuite/libjava.jacks/jacks.xfail @@ -152,8 +152,8 @@ 15.11.2-syntax-1 15.12.1-syntax-1 15.12.1-type-14 -15.12.2.1-accessibility-method-3 -15.12.2.1-accessibility-method-5 +15.12.2.1-accessibility-method-2 +15.12.2.1-accessibility-method-4 15.12.2.1-accessibility-method-6 15.12.2.2-ambiguous-10 15.12.2.2-ambiguous-12