[clang] [clang] Exclude non-template classes when checking if constraint refers to containing template arguments (PR #74265)

Erich Keane via cfe-commits cfe-commits at lists.llvm.org
Mon Dec 4 07:42:26 PST 2023


================
@@ -0,0 +1,34 @@
+// RUN: %clang_cc1 -std=c++20 -verify %s
+
+template<class T, class U>
+concept C = true;
+
+class non_temp {
+    template<C<non_temp> T>
+    friend void f();
+
+    non_temp();
+};
+
+template<C<non_temp> T>
+void f() {
+    auto v = non_temp();
+}
+
+template<class A>
+class temp {
+    template<C<temp> T>
+    friend void g();
----------------
erichkeane wrote:

We should actually be erroring on this IIRC.  The fact that this is not a definition should be an error.  GCC says: `error: friend function template with constraints that depend on outer template parameters must be a definition`

https://github.com/llvm/llvm-project/pull/74265


More information about the cfe-commits mailing list