aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNathaniel Shead <nathanieloshead@gmail.com>2025-12-09 23:33:41 +1100
committerNathaniel Shead <nathanieloshead@gmail.com>2025-12-09 23:35:32 +1100
commit49c4b7328379df066a414535166916bb017033cf (patch)
treea116e5d61ba6244a2b1948d81776b7e5f4fc9814
parent64d5e1eb97f198c9377c393d648c8db2617a80d0 (diff)
downloadgcc-49c4b7328379df066a414535166916bb017033cf.zip
gcc-49c4b7328379df066a414535166916bb017033cf.tar.gz
gcc-49c4b7328379df066a414535166916bb017033cf.tar.bz2
Revert "c++: Non-inline temploid friends should still be COMDAT [PR122819]"
This reverts commit cf22e30f0cfae65dd012966cab657583e2be667e.
-rw-r--r--gcc/cp/decl.cc6
-rw-r--r--gcc/cp/decl2.cc5
-rw-r--r--gcc/cp/semantics.cc4
-rw-r--r--gcc/testsuite/g++.dg/modules/tpl-friend-22.C24
4 files changed, 7 insertions, 32 deletions
diff --git a/gcc/cp/decl.cc b/gcc/cp/decl.cc
index 31081b3..74c862e 100644
--- a/gcc/cp/decl.cc
+++ b/gcc/cp/decl.cc
@@ -19750,7 +19750,7 @@ start_preparsed_function (tree decl1, tree attrs, int flags)
}
}
- bool honor_interface = (!DECL_TEMPLOID_INSTANTIATION (decl1)
+ bool honor_interface = (!DECL_TEMPLATE_INSTANTIATION (decl1)
/* Implicitly-defined methods (like the
destructor for a class in which no destructor
is explicitly declared) must not be defined
@@ -19781,7 +19781,7 @@ start_preparsed_function (tree decl1, tree attrs, int flags)
else if (!finfo->interface_unknown && honor_interface)
{
if (DECL_DECLARED_INLINE_P (decl1)
- || DECL_TEMPLOID_INSTANTIATION (decl1))
+ || DECL_TEMPLATE_INSTANTIATION (decl1))
{
DECL_EXTERNAL (decl1)
= (finfo->interface_only
@@ -19823,7 +19823,7 @@ start_preparsed_function (tree decl1, tree attrs, int flags)
DECL_EXTERNAL (decl1) = 0;
if ((DECL_DECLARED_INLINE_P (decl1)
- || DECL_TEMPLOID_INSTANTIATION (decl1))
+ || DECL_TEMPLATE_INSTANTIATION (decl1))
&& ! DECL_INTERFACE_KNOWN (decl1))
DECL_DEFER_OUTPUT (decl1) = 1;
else
diff --git a/gcc/cp/decl2.cc b/gcc/cp/decl2.cc
index 01bf26b..8ec9740 100644
--- a/gcc/cp/decl2.cc
+++ b/gcc/cp/decl2.cc
@@ -2510,7 +2510,7 @@ vague_linkage_p (tree decl)
|| (TREE_CODE (decl) == FUNCTION_DECL
&& DECL_DECLARED_INLINE_P (decl))
|| (DECL_LANG_SPECIFIC (decl)
- && DECL_TEMPLOID_INSTANTIATION (decl))
+ && DECL_TEMPLATE_INSTANTIATION (decl))
|| (VAR_P (decl) && DECL_INLINE_VAR_P (decl)))
return true;
else if (DECL_FUNCTION_SCOPE_P (decl))
@@ -5850,7 +5850,8 @@ c_parse_final_cleanups (void)
&& !(header_module_p ()
&& (DECL_DEFAULTED_FN (decl) || decl_tls_wrapper_p (decl)))
/* Don't complain if the template was defined. */
- && !(DECL_TEMPLOID_INSTANTIATION (decl)
+ && !((DECL_TEMPLATE_INSTANTIATION (decl)
+ || DECL_FRIEND_PSEUDO_TEMPLATE_INSTANTIATION (decl))
&& DECL_INITIAL (DECL_TEMPLATE_RESULT
(template_for_substitution (decl))))
&& warning_at (DECL_SOURCE_LOCATION (decl), 0,
diff --git a/gcc/cp/semantics.cc b/gcc/cp/semantics.cc
index b32ab2f..331db16 100644
--- a/gcc/cp/semantics.cc
+++ b/gcc/cp/semantics.cc
@@ -5537,9 +5537,7 @@ expand_or_defer_fn_1 (tree fn)
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)
- || DECL_FRIEND_PSEUDO_TEMPLATE_INSTANTIATION (fn))
+ if (DECL_DECLARED_INLINE_P (fn) || DECL_IMPLICIT_INSTANTIATION (fn))
{
if (DECL_INTERFACE_KNOWN (fn))
/* We've already made a decision as to how this function will
diff --git a/gcc/testsuite/g++.dg/modules/tpl-friend-22.C b/gcc/testsuite/g++.dg/modules/tpl-friend-22.C
deleted file mode 100644
index a77d1cb..0000000
--- a/gcc/testsuite/g++.dg/modules/tpl-friend-22.C
+++ /dev/null
@@ -1,24 +0,0 @@
-// 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" } }