This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

C++ PATCH for c++/37256


Pretty straightforward; the extra check that we need to be able to instantiate an explicitly instantiated template doesn't apply to 'extern template'.

Tested x86_64-pc-linux-gnu, applied to trunk.
2008-11-18  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'.
	* g++.dg/cpp0x/extern_template-3.C: New test.

Index: cp/pt.c
===================================================================
*** cp/pt.c	(revision 142004)
--- cp/pt.c	(working copy)
*************** instantiate_decl (tree d, int defer_ok,
*** 15226,15232 ****
        input_location = saved_loc;
  
        if (at_eof && !pattern_defined
! 	  && DECL_EXPLICIT_INSTANTIATION (d))
  	/* [temp.explicit]
  
  	   The definition of a non-exported function template, a
--- 15226,15233 ----
        input_location = saved_loc;
  
        if (at_eof && !pattern_defined
! 	  && DECL_EXPLICIT_INSTANTIATION (d)
! 	  && DECL_NOT_REALLY_EXTERN (d))
  	/* [temp.explicit]
  
  	   The definition of a non-exported function template, a
Index: testsuite/g++.dg/cpp0x/extern_template-3.C
===================================================================
*** testsuite/g++.dg/cpp0x/extern_template-3.C	(revision 0)
--- testsuite/g++.dg/cpp0x/extern_template-3.C	(revision 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();
+ }

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]