[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
This commit is contained in:
parent
55124c4e60
commit
8a26ecc0b7
2 changed files with 14 additions and 1 deletions
|
|
@ -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@-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>
|
||||
|
|
|
|||
|
|
@ -19304,7 +19304,7 @@
|
|||
<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>
|
||||
|
|
|
|||
Loading…
Reference in a new issue