[clang] [Concepts] Avoid substituting into constraints for invalid TemplateDecls (PR #75697)

Younan Zhang via cfe-commits cfe-commits at lists.llvm.org
Wed Jul 17 02:29:55 PDT 2024


================
@@ -227,3 +227,20 @@ struct r6 {};
 
 using r6i = r6<int>;
 // expected-error at -1 {{constraints not satisfied for class template 'r6' [with T = int]}}
+
+namespace GH73885 {
+
+template <class> // expected-error {{extraneous}}
+template <class T> requires(T{})
+bool e_v = true;
+
+static_assert(e_v<bool>);
+
+// We do accept the following as an extension. See Sema::MatchTemplateParametersToScopeSpecifier()
+template <>  // expected-warning {{extraneous}}
+template <class T> requires(T{true})
+constexpr bool e = true;
----------------
zyn0217 wrote:

This is brought by https://github.com/llvm/llvm-project/commit/65911498eff34ac4fc2f9c250efd49aa51c35f85, which I think is inappropriate nowadays but we probably need to keep it for ... historical reasons?

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


More information about the cfe-commits mailing list