From da3933ba836ad0821dfb7522fc9d6b9099969299 Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Wed, 19 Nov 2008 14:27:29 -0500 Subject: [PATCH] re PR c++/37256 (extern template / explicit instantiation broken in 4.4.0-pre) 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 | 6 ++++++ gcc/cp/pt.c | 3 ++- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/g++.dg/cpp0x/extern_template-3.C | 16 ++++++++++++++++ 4 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/g++.dg/cpp0x/extern_template-3.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 4353263eaba..8ce3cfe3827 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2008-11-19 Jason Merrill + + 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 Jakub Jelinek diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 13a236101b5..2b938c36881 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -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 diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 4c2dd00f48a..53a99dedc5d 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2008-11-19 Jason Merrill + + PR c++/37256 + * g++.dg/cpp0x/extern_template-3.C: New test. + 2008-11-19 Maxim Kuvyrkov * 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 index 00000000000..1b7ad0e0198 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/extern_template-3.C @@ -0,0 +1,16 @@ +// PR c++/37256 +// { dg-options "-O" } + +template +struct B +{ + T_ f(); +}; + +extern template class B; + +void f() +{ + B t; + t.f(); +} -- 2.30.2