[clang] 8a26ecc - [clang][NFC] Mark CWG2785 as implemented and add a test (#195547)
via cfe-commits
cfe-commits at lists.llvm.org
Mon May 4 10:16:49 PDT 2026
Author: Victor Chernyakin
Date: 2026-05-04T10:16:45-07:00
New Revision: 8a26ecc0b721f882d609bbd9e89af50c63b07abe
URL: https://github.com/llvm/llvm-project/commit/8a26ecc0b721f882d609bbd9e89af50c63b07abe
DIFF: https://github.com/llvm/llvm-project/commit/8a26ecc0b721f882d609bbd9e89af50c63b07abe.diff
LOG: [clang][NFC] Mark CWG2785 as implemented and add a test (#195547)
[CWG2785](https://wg21.link/cwg2785) clarifies that a
*requires-expression* is never type-dependent, it always has type
`bool`. That means that in a snippet like this:
```cpp
void g(void *);
template <typename T>
void f() {
g(requires { T(); });
}
```
The call to `g` should be diagnosed as invalid (`bool` is not
convertible to `void *`) even if the template is never instantiated.
Clang does the right thing since version 10:
https://godbolt.org/z/s61rEbsfz
Added:
Modified:
clang/test/CXX/drs/cwg27xx.cpp
clang/www/cxx_dr_status.html
Removed:
################################################################################
diff --git a/clang/test/CXX/drs/cwg27xx.cpp b/clang/test/CXX/drs/cwg27xx.cpp
index 29fe6ca86e773..6b110fd4ed97f 100644
--- a/clang/test/CXX/drs/cwg27xx.cpp
+++ b/clang/test/CXX/drs/cwg27xx.cpp
@@ -204,6 +204,19 @@ void g() {
} // namespace cwg2780
+namespace cwg2785 { // cwg2785: 10
+#if __cplusplus >= 202002L
+void g(void *); // #cwg2785-g
+
+template <typename T>
+void f() {
+ g(requires { T(); });
+ // since-cxx20-error at -1 {{no matching function for call to 'g'}}
+ // since-cxx20-note@#cwg2785-g {{candidate function not viable: no known conversion from 'bool' to 'void *' for 1st argument}}
+}
+#endif
+} // namespace cwg2785
+
namespace cwg2789 { // cwg2789: 18
#if __cplusplus >= 202302L
template <typename T = int>
diff --git a/clang/www/cxx_dr_status.html b/clang/www/cxx_dr_status.html
index cc290eabd943b..c3571b59ba874 100755
--- a/clang/www/cxx_dr_status.html
+++ b/clang/www/cxx_dr_status.html
@@ -19304,7 +19304,7 @@ <h2 id="cxxdr">C++ defect report implementation status</h2>
<td>[<a href="https://wg21.link/temp.dep.expr">temp.dep.expr</a>]</td>
<td>CD7</td>
<td>Type-dependence of <I>requires-expression</I></td>
- <td class="unknown" align="center">Unknown</td>
+ <td class="full" align="center">Clang 10</td>
</tr>
<tr class="open" id="2786">
<td><a href="https://cplusplus.github.io/CWG/issues/2786.html">2786</a></td>
More information about the cfe-commits
mailing list