re PR java/21436 (imports not remembered for previously compiled files)
authorPaolo Bonzini <bonzini@gcc.gnu.org>
Tue, 10 May 2005 13:23:35 +0000 (13:23 +0000)
committerPaolo Bonzini <bonzini@gcc.gnu.org>
Tue, 10 May 2005 13:23:35 +0000 (13:23 +0000)
gcc/java:
2005-05-10  Paolo Bonzini  <bonzini@gnu.org>

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  <bonzini@gnu.org>

PR java/21436
* testsuite/libjava.jacks/jacks.xfail: Adjust.

From-SVN: r99513

gcc/java/ChangeLog
gcc/java/class.c
gcc/java/parse.h
gcc/java/parse.y
libjava/ChangeLog
libjava/testsuite/libjava.jacks/jacks.xfail

index 5b3adf8c6d7067f9c4a10d83600cae1a8ab3d23d..5da68340ad32affdcfea16de3cdb92d82be64bc9 100644 (file)
@@ -1,3 +1,21 @@
+2005-05-10  Paolo Bonzini  <bonzini@gnu.org>
+
+       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  <fitzsim@redhat.com>
 
        PR java/20309
        (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
index 321c1e495542fa0d707d644a1ffd47100ad01ae9..9ab88570d03cb0ee9aa099ce23f365b0592e550d 100644 (file)
@@ -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. */
index 5948348895a0d454d0933347c6bd08bfbe6f1300..232eead9862fcd143ec68b744e9706f2efa2d28f 100644 (file)
@@ -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 */
index 860725f11bcdc9fed22eb5c92c9bdb16c2e367f9..b4facbba592e50bd88313a88ec607bea1a6eeabb 100644 (file)
@@ -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$<n> field, Replicate final locals still in
      scope as private final fields mangled like val$<local_name>.
      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))
     {
index f4b584d793e5be5de97adc62a58ddc3365f0c81e..bbcff752642e5b718c1cca4c62eac1b7fd4ce517 100644 (file)
@@ -1,3 +1,8 @@
+2005-05-10  Paolo Bonzini  <bonzini@gnu.org>
+
+       PR java/21436
+       * testsuite/libjava.jacks/jacks.xfail: Adjust.
+
 2005-05-09  Mike Stump  <mrs@apple.com>
 
        * configure: Regenerate.
index 85d857815d168d48dfd82d3dbdbf846521014a90..4cc878464fd6ef883ab0162d92e677c71d4e9c32 100644 (file)
 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