re PR c++/37256 (extern template / explicit instantiation broken in 4.4.0-pre)
authorJason Merrill <jason@redhat.com>
Wed, 19 Nov 2008 19:27:29 +0000 (14:27 -0500)
committerJason Merrill <jason@gcc.gnu.org>
Wed, 19 Nov 2008 19:27:29 +0000 (14:27 -0500)
        PR c++/37256
        * pt.c (instantiate_decl): Don't require a definition of
        a template that is explicitly instantiated 'extern'.

From-SVN: r142014

gcc/cp/ChangeLog
gcc/cp/pt.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/cpp0x/extern_template-3.C [new file with mode: 0644]

index 4353263eabad1682c7f2f6933b4b93ddbceb53fb..8ce3cfe3827f498a56070f553657152e36ca1357 100644 (file)
@@ -1,3 +1,9 @@
+2008-11-19  Jason Merrill  <jason@redhat.com>
+
+       PR c++/37256
+       * pt.c (instantiate_decl): Don't require a definition of
+       a template that is explicitly instantiated 'extern'.
+
 2008-11-18  Jason Merrill  <jason@redhat.com>
            Jakub Jelinek  <jakub@redhat.com>
        
index 13a236101b524f8eb363f36224667b9cc3f4fe9b..2b938c36881b75cd42b2a86c5b4044e9c15be3c6 100644 (file)
@@ -15226,7 +15226,8 @@ instantiate_decl (tree d, int defer_ok,
       input_location = saved_loc;
 
       if (at_eof && !pattern_defined
-         && DECL_EXPLICIT_INSTANTIATION (d))
+         && DECL_EXPLICIT_INSTANTIATION (d)
+         && DECL_NOT_REALLY_EXTERN (d))
        /* [temp.explicit]
 
           The definition of a non-exported function template, a
index 4c2dd00f48a6fb661594255903cc43e12eeaab22..53a99dedc5d867b64b97ac6d0704b5447f594ccb 100644 (file)
@@ -1,3 +1,8 @@
+2008-11-19  Jason Merrill  <jason@redhat.com>
+
+       PR c++/37256
+       * g++.dg/cpp0x/extern_template-3.C: New test.
+
 2008-11-19  Maxim Kuvyrkov  <maxim@codesourcery.com>
 
        * gcc.target/m68k/xgot-1.c (dg-options): Add -O2.
diff --git a/gcc/testsuite/g++.dg/cpp0x/extern_template-3.C b/gcc/testsuite/g++.dg/cpp0x/extern_template-3.C
new file mode 100644 (file)
index 0000000..1b7ad0e
--- /dev/null
@@ -0,0 +1,16 @@
+// PR c++/37256
+// { dg-options "-O" }
+
+template <typename T_>
+struct B
+{
+  T_ f();
+};
+
+extern template class B<int>;
+
+void f()
+{
+  B<int> t;
+  t.f();
+}