diff options
author | Patrick Palka <ppalka@redhat.com> | 2024-06-12 20:05:05 -0400 |
---|---|---|
committer | Patrick Palka <ppalka@redhat.com> | 2024-06-17 10:14:43 -0400 |
commit | 9583f781e17d4da881ee64db43af939402331413 (patch) | |
tree | e3e56b34e7298b706a3ff108b64da585bb448888 | |
parent | 0ed63e3791345a9933cbbf28594ab5549d336bd4 (diff) | |
download | gcc-9583f781e17d4da881ee64db43af939402331413.zip gcc-9583f781e17d4da881ee64db43af939402331413.tar.gz gcc-9583f781e17d4da881ee64db43af939402331413.tar.bz2 |
c++: visibility wrt concept-id as targ [PR115283]
Like with alias templates, it seems we don't maintain visibility flags
for concepts either, so min_vis_expr_r should ignore them for now.
Otherwise after r14-6789 we may incorrectly give a function template that
uses a concept-id in its signature internal linkage.
PR c++/115283
gcc/cp/ChangeLog:
* decl2.cc (min_vis_expr_r) <case TEMPLATE_DECL>: Ignore
concepts.
gcc/testsuite/ChangeLog:
* g++.dg/template/linkage5.C: New test.
Reviewed-by: Jason Merrill <jason@redhat.com>
(cherry picked from commit b1fe718cbe0c8883af89f52e0aad3ebf913683de)
-rw-r--r-- | gcc/cp/decl2.cc | 5 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/template/linkage5.C | 14 |
2 files changed, 17 insertions, 2 deletions
diff --git a/gcc/cp/decl2.cc b/gcc/cp/decl2.cc index 806a2a4..88933be 100644 --- a/gcc/cp/decl2.cc +++ b/gcc/cp/decl2.cc @@ -2710,9 +2710,10 @@ min_vis_expr_r (tree *tp, int */*walk_subtrees*/, void *data) break; case TEMPLATE_DECL: - if (DECL_ALIAS_TEMPLATE_P (t)) + if (DECL_ALIAS_TEMPLATE_P (t) || standard_concept_p (t)) /* FIXME: We don't maintain TREE_PUBLIC / DECL_VISIBILITY for - alias templates so we can't trust it here (PR107906). */ + alias templates so we can't trust it here (PR107906). Ditto + for concepts. */ break; t = DECL_TEMPLATE_RESULT (t); /* Fall through. */ diff --git a/gcc/testsuite/g++.dg/template/linkage5.C b/gcc/testsuite/g++.dg/template/linkage5.C new file mode 100644 index 0000000..7e8f93f --- /dev/null +++ b/gcc/testsuite/g++.dg/template/linkage5.C @@ -0,0 +1,14 @@ +// PR c++/115283 +// { dg-final { scan-assembler "(weak|glob)\[^\n\]*_Z1fIiEv1AIX1CIT_EEE" } } +// { dg-do compile { target c++20 } } + +template<class T> +concept C = true; + +template<bool B> +struct A { }; + +template<class T> +void f(A<C<T>>) { } + +template void f<int>(A<true>); |