]> gcc.gnu.org Git - gcc.git/commitdiff
re PR c++/10551 (Failure to emit explicitly instantiated template w/--no-implicit...
authorMark Mitchell <mark@codesourcery.com>
Tue, 29 Apr 2003 22:15:34 +0000 (22:15 +0000)
committerMark Mitchell <mmitchel@gcc.gnu.org>
Tue, 29 Apr 2003 22:15:34 +0000 (22:15 +0000)
PR c++/10551
* pt.c (mark_decl_instantiated): Defer all explicit instantiations
that have not yet been written out.

PR c++/10551
* g++.dg/template/explicit1.C: New test.

From-SVN: r66263

gcc/cp/ChangeLog
gcc/cp/pt.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/template/explicit1.C [new file with mode: 0644]

index 3da06762f4bffef19a4010333e02e3fc8b48df5a..f255e1390b1d79232198679e73f8642f47e54473 100644 (file)
@@ -1,3 +1,9 @@
+2003-04-29  Mark Mitchell  <mark@codesourcery.com>
+
+       PR c++/10551
+       * pt.c (mark_decl_instantiated): Defer all explicit instantiations
+       that have not yet been written out.
+
 2003-04-29  Mark Mitchell  <mark@codesourcery.com>
 
        PR c++/10549
index 02d910d5f34abe34012a1f89135c74cd9d171826..52df60b59cf84991e6697fe88878fe87d817f14d 100644 (file)
@@ -9915,11 +9915,6 @@ mark_decl_instantiated (result, extern_p)
      tree result;
      int extern_p;
 {
-  if (TREE_CODE (result) != FUNCTION_DECL)
-    /* The TREE_PUBLIC flag for function declarations will have been
-       set correctly by tsubst.  */
-    TREE_PUBLIC (result) = 1;
-
   /* We used to set this unconditionally; we moved that to
      do_decl_instantiation so it wouldn't get set on members of
      explicit class template instantiations.  But we still need to set
@@ -9928,6 +9923,16 @@ mark_decl_instantiated (result, extern_p)
   if (extern_p)
     SET_DECL_EXPLICIT_INSTANTIATION (result);
 
+  /* If this entity has already been written out, it's too late to
+     make any modifications.  */
+  if (TREE_ASM_WRITTEN (result))
+    return;
+
+  if (TREE_CODE (result) != FUNCTION_DECL)
+    /* The TREE_PUBLIC flag for function declarations will have been
+       set correctly by tsubst.  */
+    TREE_PUBLIC (result) = 1;
+
   if (! extern_p)
     {
       DECL_INTERFACE_KNOWN (result) = 1;
@@ -9941,7 +9946,8 @@ mark_decl_instantiated (result, extern_p)
       else if (TREE_PUBLIC (result))
        maybe_make_one_only (result);
     }
-  else if (TREE_CODE (result) == FUNCTION_DECL)
+
+  if (TREE_CODE (result) == FUNCTION_DECL)
     defer_fn (result);
 }
 
index 9fba7a37219f7d4c68d506bfa6b5814f29fe9ff7..4a0d42cbea2577395f9dda27af021b7425afce9a 100644 (file)
@@ -1,3 +1,8 @@
+2003-04-29  Mark Mitchell  <mark@codesourcery.com>
+
+       PR c++/10551
+       * g++.dg/template/explicit1.C: New test.
+
 2003-04-29  Mark Mitchell  <mark@codesourcery.com>
 
        PR c++/10549
diff --git a/gcc/testsuite/g++.dg/template/explicit1.C b/gcc/testsuite/g++.dg/template/explicit1.C
new file mode 100644 (file)
index 0000000..64f581e
--- /dev/null
@@ -0,0 +1,17 @@
+// { dg-do link }
+// { dg-options "-fno-implicit-templates" }
+
+template <class T> struct C {
+  ~C();
+};
+template <class T> C<T>::~C() {}
+
+struct X {
+  C<X> *p;
+  ~X() { delete p; }
+};
+
+template class C<X>;
+C<X> x;
+
+int main () {}
This page took 0.124894 seconds and 5 git commands to generate.