https://github.com/imdj updated https://github.com/llvm/llvm-project/pull/132919

>From 7905577616743f5158560a4b337148ef9cd25f1e Mon Sep 17 00:00:00 2001
From: Imad Aldij <o...@imadij.com>
Date: Tue, 25 Mar 2025 14:50:55 +0200
Subject: [PATCH 1/5] [Clang] Implement CWG2517 Useless restriction on use of
 parameter in constraint-expression

---
 clang/lib/Sema/SemaExpr.cpp | 11 -----------
 1 file changed, 11 deletions(-)

diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 3af6d6c23438f..fa8eeb644c179 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -396,17 +396,6 @@ bool Sema::DiagnoseUseOfDecl(NamedDecl *D, 
ArrayRef<SourceLocation> Locs,
           targetDiag(*Locs.begin(), diag::err_thread_unsupported);
   }
 
-  if (isa<ParmVarDecl>(D) && isa<RequiresExprBodyDecl>(D->getDeclContext()) &&
-      !isUnevaluatedContext()) {
-    // C++ [expr.prim.req.nested] p3
-    //   A local parameter shall only appear as an unevaluated operand
-    //   (Clause 8) within the constraint-expression.
-    Diag(Loc, 
diag::err_requires_expr_parameter_referenced_in_evaluated_context)
-        << D;
-    Diag(D->getLocation(), diag::note_entity_declared_at) << D;
-    return true;
-  }
-
   return false;
 }
 

>From a3b573c1d1f7120c9a1caa7e6fad42a5309679f0 Mon Sep 17 00:00:00 2001
From: Imad Aldij <o...@imadij.com>
Date: Tue, 25 Mar 2025 15:04:15 +0200
Subject: [PATCH 2/5] Remove old tests

---
 .../expr/expr.prim/expr.prim.req/nested-requirement.cpp    | 7 -------
 .../expr/expr.prim/expr.prim.req/simple-requirement.cpp    | 7 -------
 2 files changed, 14 deletions(-)

diff --git a/clang/test/CXX/expr/expr.prim/expr.prim.req/nested-requirement.cpp 
b/clang/test/CXX/expr/expr.prim/expr.prim.req/nested-requirement.cpp
index 763d983d20f61..eaef4441c10f8 100644
--- a/clang/test/CXX/expr/expr.prim/expr.prim.req/nested-requirement.cpp
+++ b/clang/test/CXX/expr/expr.prim/expr.prim.req/nested-requirement.cpp
@@ -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}}
 }
 
 template<typename T>
diff --git a/clang/test/CXX/expr/expr.prim/expr.prim.req/simple-requirement.cpp 
b/clang/test/CXX/expr/expr.prim/expr.prim.req/simple-requirement.cpp
index 7515f5c62d5ea..0b6d9e147b3d1 100644
--- a/clang/test/CXX/expr/expr.prim/expr.prim.req/simple-requirement.cpp
+++ b/clang/test/CXX/expr/expr.prim/expr.prim.req/simple-requirement.cpp
@@ -98,13 +98,6 @@ namespace std_example {
   using c1c2 = C_check<int *>; // expected-error{{constraints not satisfied 
for class template 'C_check' [with T = int *]}}
 }
 
-// typeid() of an expression becomes potentially evaluated if the expression is
-// of a polymorphic type.
-class X { virtual ~X(); };
-constexpr bool b = requires (X &x) { static_cast<int(*)[(typeid(x), 
0)]>(nullptr); };
-// expected-error@-1{{constraint variable 'x' cannot be used in an evaluated 
context}}
-// expected-note@-2{{'x' declared here}}
-
 namespace access_checks {
 namespace in_requires_expression {
 template<auto>

>From bbd033d24b3a625d448fb9e7267af54a202e41d7 Mon Sep 17 00:00:00 2001
From: Imad Aldij <o...@imadij.com>
Date: Tue, 25 Mar 2025 15:05:17 +0200
Subject: [PATCH 3/5] Add test associated with CWG2517

---
 clang/test/CXX/drs/cwg25xx.cpp | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/clang/test/CXX/drs/cwg25xx.cpp b/clang/test/CXX/drs/cwg25xx.cpp
index d9a7d2bbb2671..bda2cc6e5e965 100644
--- a/clang/test/CXX/drs/cwg25xx.cpp
+++ b/clang/test/CXX/drs/cwg25xx.cpp
@@ -32,6 +32,26 @@ enum E2 : S<E2>::I { e };
 #endif
 } // namespace cwg2516
 
+namespace cwg2517 { // cwg2517: 23
+#if __cplusplus >= 202302L
+template<typename ArrayType>
+concept LargeArray = requires (ArrayType my_array) {
+  requires my_array.size() > 5;
+};
+
+struct Big {
+  constexpr int size() const { return 100; }
+};
+
+struct Small {
+  constexpr int size() const { return 3; }
+};
+
+static_assert(LargeArray<Big>);
+static_assert(!LargeArray<Small>);
+#endif
+} // namespace cwg2517
+
 namespace cwg2518 { // cwg2518: 17
 
 #if __cplusplus >= 201103L

>From 159505e515da00e6006cba1a68766a5522981d8b Mon Sep 17 00:00:00 2001
From: Imad Aldij <o...@imadij.com>
Date: Tue, 25 Mar 2025 15:07:46 +0200
Subject: [PATCH 4/5] Update cxx_dr_status.html

---
 clang/www/cxx_dr_status.html | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang/www/cxx_dr_status.html b/clang/www/cxx_dr_status.html
index 16a9b26052f87..21fd1c8c965b7 100755
--- a/clang/www/cxx_dr_status.html
+++ b/clang/www/cxx_dr_status.html
@@ -14937,7 +14937,7 @@ <h2 id="cxxdr">C++ defect report implementation 
status</h2>
     <td><a 
href="https://cplusplus.github.io/CWG/issues/2517.html";>2517</a></td>
     <td>C++23</td>
     <td>Useless restriction on use of parameter in 
<I>constraint-expression</I></td>
-    <td class="unknown" align="center">Unknown</td>
+    <td class="full" align="center">Clang 23</td>
   </tr>
   <tr id="2518">
     <td><a 
href="https://cplusplus.github.io/CWG/issues/2518.html";>2518</a></td>

>From 229ffbbfa83b596f01e750d8c957ed6b3c9a900d Mon Sep 17 00:00:00 2001
From: Imad Aldij <o...@imadij.com>
Date: Tue, 25 Mar 2025 15:18:41 +0200
Subject: [PATCH 5/5] Add release notes

---
 clang/docs/ReleaseNotes.rst | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 2f15c90ab1583..41a54959977e1 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -116,6 +116,9 @@ Resolutions to C++ Defect Reports
 - Bumped the ``__cpp_constexpr`` feature-test macro to ``202002L`` in C++20 
mode as indicated in
   `P2493R0 <https://wg21.link/P2493R0>`_.
 
+- Implemented `CWG2517 Useless restriction on use of parameter in 
constraint-expression `
+  `<https://cplusplus.github.io/CWG/issues/2517.html>`_.
+
 C Language Changes
 ------------------
 

_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to