re PR java/13183 ([unit-at-a-time] incorrect multidimensional array initializer with...
authorJeff Sturm <jsturm@one-point.com>
Tue, 25 Nov 2003 17:32:54 +0000 (17:32 +0000)
committerJeff Sturm <jsturm@gcc.gnu.org>
Tue, 25 Nov 2003 17:32:54 +0000 (17:32 +0000)
Fix PR java/13183.
* constants.c (cpool_for_class): New function.
(outgoing_cpool): Remove global variable.
(alloc_name_constant): Use cpool_for_class.
(build_constants_constructor): Likewise.
* decl.c (java_expand_body): Set current_class.
* java-tree.h (outgoing_cpool) Remove declaration.
(init_outgoing_cpool): Likewise.
* jcf-parse.c (init_outgoing_cpool): Remove function.
(parse_class_file): Don't call init_outgoing_cpool.
* parse.y (java_complete_expand_methods): Don't call
init_outgoing_cpool.  Don't save outgoing_cpool.
(java_expand_classes): Don't restore outgoing_cpool.
(java_finish_classes): Likewise.

From-SVN: r73926

gcc/java/ChangeLog
gcc/java/constants.c
gcc/java/decl.c
gcc/java/java-tree.h
gcc/java/jcf-parse.c
gcc/java/parse.y

index 4c7afae..1a34e36 100644 (file)
@@ -1,3 +1,20 @@
+2003-11-25  Jeff Sturm  <jsturm@one-point.com>
+
+       Fix PR java/13183.
+       * constants.c (cpool_for_class): New function.
+       (outgoing_cpool): Remove global variable.
+       (alloc_name_constant): Use cpool_for_class.
+       (build_constants_constructor): Likewise.
+       * decl.c (java_expand_body): Set current_class.
+       * java-tree.h (outgoing_cpool) Remove declaration.
+       (init_outgoing_cpool): Likewise.
+       * jcf-parse.c (init_outgoing_cpool): Remove function.
+       (parse_class_file): Don't call init_outgoing_cpool.
+       * parse.y (java_complete_expand_methods): Don't call
+       init_outgoing_cpool.  Don't save outgoing_cpool.
+       (java_expand_classes): Don't restore outgoing_cpool.
+       (java_finish_classes): Likewise.
+
 2003-11-24  Mohan Embar  <gnustuff@thisiscool.com>
 
        * Make-lang.in: (java.install-common) Add
index 274a8bf..8a1fe1b 100644 (file)
@@ -37,6 +37,7 @@ static int find_class_or_string_constant (CPool *, int, tree);
 static int find_name_and_type_constant (CPool *, tree, tree);
 static tree get_tag_node (int);
 static tree build_constant_data_ref (void);
+static CPool *cpool_for_class (tree);
 
 /* Set the INDEX'th constant in CPOOL to have the given TAG and VALUE. */
 
@@ -315,8 +316,6 @@ write_constant_pool (CPool *cpool, unsigned char *buffer, int length)
     abort ();
 }
 
-CPool *outgoing_cpool;
-
 static GTY(()) tree tag_nodes[13];
 static tree
 get_tag_node (int tag)
@@ -328,6 +327,21 @@ get_tag_node (int tag)
   return tag_nodes[tag];
 }
 
+/* Given a class, return its constant pool, creating one if necessary.  */
+
+static CPool *
+cpool_for_class (tree class)
+{
+  CPool *cpool = TYPE_CPOOL (class);
+
+  if (cpool == NULL)
+    {
+      cpool = ggc_alloc_cleared (sizeof (struct CPool));
+      TYPE_CPOOL (class) = cpool;
+    }
+  return cpool;
+}
+
 /* Look for a constant pool entry that matches TAG and NAME.
    Creates a new entry if not found.
    TAG is one of CONSTANT_Utf8, CONSTANT_String or CONSTANT_Class.
@@ -337,6 +351,7 @@ get_tag_node (int tag)
 int
 alloc_name_constant (int tag, tree name)
 {
+  CPool *outgoing_cpool = cpool_for_class (current_class);
   return find_tree_constant (outgoing_cpool, tag, name);
 }
 
@@ -414,6 +429,7 @@ build_ref_from_constant_pool (int index)
 tree
 build_constants_constructor (void)
 {
+  CPool *outgoing_cpool = cpool_for_class (current_class);
   tree tags_value, data_value;
   tree cons;
   tree tags_list = NULL_TREE;
index b8f09e1..014fcc7 100644 (file)
@@ -1860,6 +1860,7 @@ java_expand_body (tree fndecl)
 
   current_function_decl = fndecl;
   input_location = DECL_SOURCE_LOCATION (fndecl);
+  current_class = DECL_CONTEXT (fndecl);
 
   timevar_push (TV_EXPAND);
 
index 2c706c9..c0ffac5 100644 (file)
@@ -694,9 +694,6 @@ extern GTY(()) tree java_global_trees[JTI_MAX];
 
 #define nativecode_ptr_type_node ptr_type_node
 
-/* They need to be reset before processing each class */
-extern GTY(()) struct CPool *outgoing_cpool; 
-
 #define wfl_operator \
   java_global_trees[JTI_WFL_OPERATOR]
 
@@ -1219,7 +1216,6 @@ extern int enclosing_context_p (tree, tree);
 extern void complete_start_java_method (tree);
 extern tree build_result_decl (tree);
 extern void emit_handlers (void);
-extern void init_outgoing_cpool (void);
 extern void make_class_data (tree);
 extern void register_class (void);
 extern int alloc_name_constant (int, tree);
index 352a0be..71d447e 100644 (file)
@@ -693,12 +693,6 @@ load_inner_classes (tree cur_class)
     }
 }
 
-void
-init_outgoing_cpool (void)
-{
-  outgoing_cpool = ggc_alloc_cleared (sizeof (struct CPool));
-}
-
 static void
 parse_class_file (void)
 {
@@ -710,7 +704,6 @@ parse_class_file (void)
   input_filename = DECL_SOURCE_FILE (TYPE_NAME (current_class));
   input_line = 0;
   (*debug_hooks->start_source_file) (input_line, input_filename);
-  init_outgoing_cpool ();
 
   /* Currently we always have to emit calls to _Jv_InitClass when
      compiling from class files.  */
index 5613c87..267198c 100644 (file)
@@ -7689,9 +7689,6 @@ java_complete_expand_methods (tree class_decl)
 
   current_class = TREE_TYPE (class_decl);
 
-  /* Initialize a new constant pool */
-  init_outgoing_cpool ();
-
   /* Pre-expand <clinit> to figure whether we really need it or
      not. If we do need it, we pre-expand the static fields so they're
      ready to be used somewhere else. <clinit> will be fully expanded
@@ -7775,9 +7772,6 @@ java_complete_expand_methods (tree class_decl)
       if (DECL_CONSTRUCTOR_P (decl)
          && verify_constructor_circularity (decl, decl))
        break;
-
-  /* Save the constant pool. We'll need to restore it later. */
-  TYPE_CPOOL (current_class) = outgoing_cpool;
 }
 
 /* Attempt to create <clinit>. Pre-expand static fields so they can be
@@ -9157,7 +9151,6 @@ java_expand_classes (void)
           current = TREE_CHAIN (current))
        {
          current_class = TREE_TYPE (TREE_VALUE (current));
-         outgoing_cpool = TYPE_CPOOL (current_class);
          if (flag_emit_class_files)
            write_classfile (current_class);
          if (flag_emit_xref)
@@ -9179,7 +9172,6 @@ java_finish_classes (void)
       for (current = ctxp->class_list; current; current = TREE_CHAIN (current))
        {
          current_class = TREE_TYPE (current);
-         outgoing_cpool = TYPE_CPOOL (current_class);
          finish_class ();
        }
     }