]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
c++: visibility wrt concept-id as targ [PR115283]
authorPatrick Palka <ppalka@redhat.com>
Thu, 13 Jun 2024 00:05:05 +0000 (20:05 -0400)
committerPatrick Palka <ppalka@redhat.com>
Thu, 13 Jun 2024 00:05:05 +0000 (20:05 -0400)
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>
gcc/cp/decl2.cc
gcc/testsuite/g++.dg/template/linkage5.C [new file with mode: 0644]

index 7baff46a1921f1b3ff404c6e12777ea44764495e..6c3ef60d51f8c837fd8e378e4cd745854805678d 100644 (file)
@@ -2723,9 +2723,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 (file)
index 0000000..7e8f93f
--- /dev/null
@@ -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>);