spew.c (pending_inlines, [...]): Make static.
authorJakub Jelinek <jakub@redhat.com>
Wed, 23 Jan 2002 18:52:08 +0000 (19:52 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Wed, 23 Jan 2002 18:52:08 +0000 (19:52 +0100)
* spew.c (pending_inlines, pending_inlines_tail,
processing_these_inlines): Make static.
(mark_pending_inlines): Remove static.
(begin_parsing_inclass_inline): If in function, save pi
for GC to cp_function_chain->unparsed_inlines instead.
(process_next_inline): Likewise.
* cp-tree.h (struct cp_language_function): Add unparsed_inlines.
(mark_pending_inlines): Add prototype.
* decl.c (spew_debug): Remove unused extern.
(mark_lang_function): Call mark_pending_inlines.

* g++.dg/other/gc1.C: New test.

From-SVN: r49147

gcc/cp/ChangeLog
gcc/cp/cp-tree.h
gcc/cp/decl.c
gcc/cp/spew.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/other/gc1.C [new file with mode: 0644]

index 9c6fce3862ae0b5281aa54c5284c9da71b00a4e1..f2c1791aee1feaa3044bf5b86f8cddebcf0239d8 100644 (file)
@@ -1,3 +1,16 @@
+2002-01-23  Jakub Jelinek  <jakub@redhat.com>
+
+       * spew.c (pending_inlines, pending_inlines_tail,
+       processing_these_inlines): Make static.
+       (mark_pending_inlines): Remove static.
+       (begin_parsing_inclass_inline): If in function, save pi
+       for GC to cp_function_chain->unparsed_inlines instead.
+       (process_next_inline): Likewise.
+       * cp-tree.h (struct cp_language_function): Add unparsed_inlines.
+       (mark_pending_inlines): Add prototype.
+       * decl.c (spew_debug): Remove unused extern.
+       (mark_lang_function): Call mark_pending_inlines.
+
 2002-01-23  Craig Rodrigues  <rodrigc@gcc.gnu.org>
 
        * call.c, class.c, decl.c, decl2.c, error.c, expr.c, friend.c, 
index 99f7bf71b7432c7b588f704ff7650321f6cb325c..8c075c51ee9d3abb481880af24121f9a0f504af7 100644 (file)
@@ -801,6 +801,8 @@ struct saved_scope
 
 extern struct saved_scope *scope_chain;
 
+struct unparsed_text;
+
 /* Global state pertinent to the current function.  */
 
 struct cp_language_function
@@ -828,6 +830,7 @@ struct cp_language_function
   varray_type x_local_names;
 
   const char *cannot_inline;
+  struct unparsed_text *unparsed_inlines;
 };
 
 /* The current C++-specific per-function global variables.  */
@@ -1781,8 +1784,6 @@ struct lang_decl_flags
   } u2;
 };
 
-struct unparsed_text;
-
 struct lang_decl
 {
   struct lang_decl_flags decl_flags;
@@ -4193,6 +4194,7 @@ extern tree finish_global_stmt_expr             PARAMS ((tree));
 
 /* in spew.c */
 extern void init_spew                          PARAMS ((void));
+extern void mark_pending_inlines               PARAMS ((PTR));
 extern int peekyylex                           PARAMS ((void));
 extern tree arbitrate_lookup                   PARAMS ((tree, tree, tree));
 extern tree frob_opname                         PARAMS ((tree));
index 3747cabe9e3e4c3b71ce0adab4c016693dda6429..35211135cf0fe319f04564b5717868c54218c4e9 100644 (file)
@@ -288,10 +288,6 @@ extern int flag_conserve_space;
 \f
 /* C and C++ flags are in decl2.c.  */
 
-/* Flag used when debugging spew.c */
-
-extern int spew_debug;
-
 /* A expression of value 0 with the same precision as a sizetype
    node, but signed.  */
 tree signed_size_zero_node;
@@ -14607,6 +14603,7 @@ mark_lang_function (p)
 
   mark_named_label_lists (&p->x_named_labels, &p->x_named_label_uses);
   mark_binding_level (&p->bindings);
+  mark_pending_inlines (&p->unparsed_inlines);
 }
 
 /* Mark the language-specific data in F for GC.  */
index 74f89a05a5376f38f98b67698956dffb2c42bf15..e610aec47c09efa946ab40286189514a07c6f97d 100644 (file)
@@ -119,15 +119,14 @@ static int frob_id PARAMS ((int, int, tree *));
 
 /* The list of inline functions being held off until we reach the end of
    the current class declaration.  */
-struct unparsed_text *pending_inlines;
-struct unparsed_text *pending_inlines_tail;
+static struct unparsed_text *pending_inlines;
+static struct unparsed_text *pending_inlines_tail;
 
 /* The list of previously-deferred inline functions currently being parsed.
    This exists solely to be a GC root.  */
-struct unparsed_text *processing_these_inlines;
+static struct unparsed_text *processing_these_inlines;
 
 static void begin_parsing_inclass_inline PARAMS ((struct unparsed_text *));
-static void mark_pending_inlines PARAMS ((PTR));
 
 #ifdef SPEW_DEBUG
 int spew_debug = 0;
@@ -416,7 +415,7 @@ end_input ()
 }
 
 /* GC callback to mark memory pointed to by the pending inline queue.  */
-static void
+void
 mark_pending_inlines (pi)
      PTR pi;
 {
@@ -950,8 +949,11 @@ begin_parsing_inclass_inline (pi)
   tree context;
 
   /* Record that we are processing the chain of inlines starting at
-     PI in a special GC root.  */
-  processing_these_inlines = pi;
+     PI for GC.  */
+  if (cfun)
+    cp_function_chain->unparsed_inlines = pi;
+  else
+    processing_these_inlines = pi;
 
   ggc_collect ();
 
@@ -1025,7 +1027,10 @@ process_next_inline (i)
     begin_parsing_inclass_inline (i);
   else
     {
-      processing_these_inlines = 0;
+      if (cfun)
+       cp_function_chain->unparsed_inlines = 0;
+      else
+       processing_these_inlines = 0;
       extract_interface_info ();
     }
 }
index 414c694a8701f4c4e468ab2a2edb0fa215312d6c..22bc8a929c44d067580c803fb68ffcf170ea9ee1 100644 (file)
@@ -1,3 +1,7 @@
+2002-01-23  Jakub Jelinek  <jakub@redhat.com>
+
+       * g++.dg/other/gc1.C: New test.
+
 2002-01-23  Zack Weinberg  <zack@codesourcery.com>
 
        * gcc.dg/c99-intconst-1.c: Mark XFAIL.
diff --git a/gcc/testsuite/g++.dg/other/gc1.C b/gcc/testsuite/g++.dg/other/gc1.C
new file mode 100644 (file)
index 0000000..3c7a169
--- /dev/null
@@ -0,0 +1,49 @@
+// This test failed with GGC_ALWAYS_COLLECT because not all unparsed
+// inline methods were registered with GC.
+// { dg-do compile }
+
+const char *foo ()
+{
+  struct A
+  {
+    const char *a1 ()
+    {
+      return "a1";
+    }
+    const char *a2 ()
+    {
+      struct B
+      {
+       const char *b1 ()
+       {
+         return "b1";
+       }
+       const char *b2 ()
+       {
+         struct C
+         {
+           const char *c1 ()
+           {
+             return "c1";
+           }
+           const char *c2 ()
+           {
+             return "c2";
+           }
+         };
+         return "b2";
+       }
+       const char *b3 ()
+       {
+         return "b3";
+       }
+      };
+      return "a2";
+    }
+    const char *a3 ()
+    {
+      return "a3";
+    }
+  };
+  return "foo";
+}