[clang] [Clang][Concepts] Fix a constraint comparison regression for out-of-line ClassTemplateDecls (PR #102587)

Younan Zhang via cfe-commits cfe-commits at lists.llvm.org
Sat Aug 10 00:35:04 PDT 2024


================
@@ -599,3 +599,39 @@ template <class DerT>
 unsigned long DerivedCollection<DerTs...>::index() {}
 
 } // namespace GH72557
+
+namespace GH102320 {
+
+template <class, class>
+concept Constrained = true;
+
+template <class T> class C {
+  template <Constrained<T>> class D;
+  template <class U>
+    requires Constrained<T, U>
+  class E;
+};
+
+template <class T> template <Constrained<T>> class C<T>::D {};
+
+template <class T>
+template <class U>
+  requires Constrained<T, U>
+class C<T>::E {};
+
+#if 0
+// FIXME: Is it conforming? Only Clang rejects it in every released version.
+template <>
+template <Constrained<int> T>
+class C<int>::D<T> {};
+#endif
+
----------------
zyn0217 wrote:

Actually there seems to be a slight discrepancy among the four compilers here:
https://gcc.godbolt.org/z/nxPoeGE5b
w/o constraints, MSVC and Clang reject such a pattern, while GCC and EDG accept it.
w/ constraints, only Clang complains. So I'm unclear about what is supposed to happen here.
@cor3ntin do you have any ideas?

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


More information about the cfe-commits mailing list