Comments
Patch
@@ -17224,8 +17224,13 @@ instantiate_decl (tree d, int defer_ok,
if (!pattern_defined && expl_inst_class_mem_p
&& DECL_EXPLICIT_INSTANTIATION (d))
{
- DECL_NOT_REALLY_EXTERN (d) = 0;
- DECL_INTERFACE_KNOWN (d) = 0;
+ /* Leave linkage flags alone on instantiations with anonymous
+ visibility. */
+ if (TREE_PUBLIC (d))
+ {
+ DECL_NOT_REALLY_EXTERN (d) = 0;
+ DECL_INTERFACE_KNOWN (d) = 0;
+ }
SET_DECL_IMPLICIT_INSTANTIATION (d);
}
new file mode 100644
@@ -0,0 +1,6 @@
+// PR c++/45651
+
+namespace { template <int T> struct A {}; }
+template <int T> struct B { void f(A<T>); };
+template struct B<1>;
+template<int T> void B<T>::f(A<T>) {}
The linkage handling of an explicit instantiation of an undefined template in instantiate_decl was interacting badly with the linkage magic for anonymous namespaces. Fixed thus. Tested x86_64-pc-linux-gnu, applied to trunk. commit bb206a6c192120614fa6e3c78a2ba2add6f5c3f2 Author: Jason Merrill <jason@redhat.com> Date: Tue Mar 8 10:54:00 2011 -0500 PR c++/45651 * pt.c (instantiate_decl): Don't clear DECL_INTERFACE_KNOWN on !TREE_PUBLIC decls.