}
}
- bool honor_interface = (!DECL_TEMPLATE_INSTANTIATION (decl1)
+ bool honor_interface = (!DECL_TEMPLOID_INSTANTIATION (decl1)
/* Implicitly-defined methods (like the
destructor for a class in which no destructor
is explicitly declared) must not be defined
else if (!finfo->interface_unknown && honor_interface)
{
if (DECL_DECLARED_INLINE_P (decl1)
- || DECL_TEMPLATE_INSTANTIATION (decl1))
+ || DECL_TEMPLOID_INSTANTIATION (decl1))
{
DECL_EXTERNAL (decl1)
= (finfo->interface_only
DECL_EXTERNAL (decl1) = 0;
if ((DECL_DECLARED_INLINE_P (decl1)
- || DECL_TEMPLATE_INSTANTIATION (decl1))
+ || DECL_TEMPLOID_INSTANTIATION (decl1))
&& ! DECL_INTERFACE_KNOWN (decl1))
DECL_DEFER_OUTPUT (decl1) = 1;
else
|| (TREE_CODE (decl) == FUNCTION_DECL
&& DECL_DECLARED_INLINE_P (decl))
|| (DECL_LANG_SPECIFIC (decl)
- && DECL_TEMPLATE_INSTANTIATION (decl))
+ && DECL_TEMPLOID_INSTANTIATION (decl))
|| (VAR_P (decl) && DECL_INLINE_VAR_P (decl)))
return true;
else if (DECL_FUNCTION_SCOPE_P (decl))
&& !(header_module_p ()
&& (DECL_DEFAULTED_FN (decl) || decl_tls_wrapper_p (decl)))
/* Don't complain if the template was defined. */
- && !((DECL_TEMPLATE_INSTANTIATION (decl)
- || DECL_FRIEND_PSEUDO_TEMPLATE_INSTANTIATION (decl))
+ && !(DECL_TEMPLOID_INSTANTIATION (decl)
&& DECL_INITIAL (DECL_TEMPLATE_RESULT
(template_for_substitution (decl))))
&& warning_at (DECL_SOURCE_LOCATION (decl), 0,
template <class T> friend A<T>::f(); */
tree tmpl = TI_TEMPLATE (ti);
tree primary = DECL_PRIMARY_TEMPLATE (tmpl);
- return (primary && primary != tmpl);
+ return ((primary || DECL_NAMESPACE_SCOPE_P (t)) && primary != tmpl);
}
else
return false;
of the compilation. Until that point, we do not want the back
end to output them -- but we do want it to see the bodies of
these functions so that it can inline them as appropriate. */
- if (DECL_DECLARED_INLINE_P (fn) || DECL_IMPLICIT_INSTANTIATION (fn))
+ if (DECL_DECLARED_INLINE_P (fn)
+ || DECL_IMPLICIT_INSTANTIATION (fn)
+ || DECL_FRIEND_PSEUDO_TEMPLATE_INSTANTIATION (fn))
{
if (DECL_INTERFACE_KNOWN (fn))
/* We've already made a decision as to how this function will
--- /dev/null
+// PR c++/122819
+// { dg-do compile { target *-*-*gnu* } }
+// { dg-additional-options "-fmodules" }
+
+export module M;
+
+template <typename T> struct S;
+void foo(S<float>);
+
+template <typename T> struct S {
+ friend void foo(S) {}
+};
+
+void foo(S<double>);
+
+void use() {
+ foo(S<int>{});
+ foo(S<float>{});
+ foo(S<double>{});
+}
+
+// { dg-final { scan-assembler "_ZW1M3fooS_1SIiE,comdat" } }
+// { dg-final { scan-assembler "_ZW1M3fooS_1SIfE,comdat" } }
+// { dg-final { scan-assembler "_ZW1M3fooS_1SIdE,comdat" } }
--- /dev/null
+// PR c++/122819
+// { dg-do compile { target c++11 } }
+
+template <typename T> struct basic_streambuf;
+using streambuf = basic_streambuf<char>;
+
+struct S {
+ void foo();
+ template <typename T> void bar();
+};
+
+template <typename T> struct X {
+ void foo();
+};
+
+template <typename T> struct basic_streambuf {
+ void qux();
+
+ friend void foo();
+ friend void S::foo();
+ template <typename U> friend void S::bar();
+ template <typename U> friend void X<U>::foo();
+ template <typename U> friend void basic_streambuf<U>::qux();
+};
+extern template struct basic_streambuf<char>;
+
+void foo() {}
+void S::foo() {}
+
+// { dg-final { scan-assembler {_Z3foov:} } }
+// { dg-final { scan-assembler {_ZN1S3fooEv:} } }
+// { dg-final { scan-assembler-not {comdat} } }