[clang] [clang][NFC] Mark CWG2629 as implemented and add a test (PR #195490)
Victor Chernyakin via cfe-commits
cfe-commits at lists.llvm.org
Sat May 2 16:04:15 PDT 2026
https://github.com/localspook created https://github.com/llvm/llvm-project/pull/195490
This is ill-formed:
```cpp
switch (0.0) {}
```
Before [CWG2629](https://wg21.link/cwg2629) though, this was allowed:
```cpp
switch (double d = 0.0) {} // Value of 'd' is implicitly converted to an integer
```
Clang however has always rejected both: https://godbolt.org/z/GYc4hhrnz
>From cad6c8d5661578dc8795ca6c84703790c339493d Mon Sep 17 00:00:00 2001
From: Victor Chernyakin <chernyakin.victor.j at outlook.com>
Date: Sat, 2 May 2026 15:59:28 -0700
Subject: [PATCH] [clang][NFC] Mark CWG2629 as implemented and add a test
---
clang/test/CXX/drs/cwg26xx.cpp | 7 +++++++
clang/www/cxx_dr_status.html | 2 +-
2 files changed, 8 insertions(+), 1 deletion(-)
diff --git a/clang/test/CXX/drs/cwg26xx.cpp b/clang/test/CXX/drs/cwg26xx.cpp
index 5fe409a3b2905..27ad8c0636a50 100644
--- a/clang/test/CXX/drs/cwg26xx.cpp
+++ b/clang/test/CXX/drs/cwg26xx.cpp
@@ -148,6 +148,13 @@ void f() {
#endif
} // namespace cwg2628
+namespace cwg2629 { // cwg2629: 2.7
+void f() {
+ switch (double d = 0.0) {}
+ // expected-error at -1 {{statement requires expression of integer type ('double' invalid)}}
+}
+} // namespace cwg2629
+
// cwg2630 is in cwg2630.cpp
namespace cwg2631 { // cwg2631: 16
diff --git a/clang/www/cxx_dr_status.html b/clang/www/cxx_dr_status.html
index feef0c3770f64..cc290eabd943b 100755
--- a/clang/www/cxx_dr_status.html
+++ b/clang/www/cxx_dr_status.html
@@ -18208,7 +18208,7 @@ <h2 id="cxxdr">C++ defect report implementation status</h2>
<td>[<a href="https://wg21.link/stmt.switch">stmt.switch</a>]</td>
<td>C++23</td>
<td>Variables of floating-point type as <TT>switch</TT> conditions</td>
- <td class="unknown" align="center">Unknown</td>
+ <td class="full" align="center">Clang 2.7</td>
</tr>
<tr id="2630">
<td><a href="https://cplusplus.github.io/CWG/issues/2630.html">2630</a></td>
More information about the cfe-commits
mailing list