[clang] [Clang] Implement CWG2517 Useless restriction on use of parameter in constraint-expression (PR #132919)
Imad Aldij via cfe-commits
cfe-commits at lists.llvm.org
Tue Mar 25 08:15:48 PDT 2025
================
@@ -37,13 +37,6 @@ namespace std_example {
static_assert(D<T1>);
template<D T> struct D_check {}; // expected-note{{because 'short' does not satisfy 'D'}}
using dc1 = D_check<short>; // expected-error{{constraints not satisfied for class template 'D_check' [with T = short]}}
-
- template<typename T>
- concept C2 = requires (T a) {
- requires sizeof(a) == 4; // OK
- requires a == 0; // expected-note{{because 'a == 0' would be invalid: constraint variable 'a' cannot be used in an evaluated context}}
- };
- static_assert(C2<int>); // expected-note{{because 'int' does not satisfy 'C2'}} expected-error{{static assertion failed}}
----------------
imdj wrote:
If we keep the tests and only remove the expected comments, this results in:
```
error: 'expected-error' diagnostics seen but not expected:
File [...]/nested-requirement.cpp Line 44: substitution into constraint expression resulted in a non-constant expression
File [...]/nested-requirement.cpp Line 46: static assertion failed
error: 'expected-note' diagnostics seen but not expected:
File [...]/nested-requirement.cpp Line 44: while checking the satisfaction of nested requirement requested here
File [...]/nested-requirement.cpp Line 44: in instantiation of requirement here
File [...]/nested-requirement.cpp Line 44: while checking the satisfaction of nested requirement requested here
File [...]/nested-requirement.cpp Line 42: while substituting template arguments into constraint expression here
File [...]/nested-requirement.cpp Line 46: while checking the satisfaction of concept 'C2<int>' requested here
File [...]/nested-requirement.cpp Line 44: function parameter 'a' with unknown value cannot be used in a constant expression
File [...]/nested-requirement.cpp Line 42: declared here
File [...]/nested-requirement.cpp Line 46: because 'int' does not satisfy 'C2'
```
Should I keep the tests and update the expected failures instead?
https://github.com/llvm/llvm-project/pull/132919
More information about the cfe-commits
mailing list