[clang] [Clang][NFC] Add test for CWG2289 "Uniqueness of structured binding names" (PR #131054)
Yanzuo Liu via cfe-commits
cfe-commits at lists.llvm.org
Wed Mar 12 19:24:12 PDT 2025
https://github.com/zwuis created https://github.com/llvm/llvm-project/pull/131054
The resolution of [CWG2289](https://wg21.link/cwg2289) added that the name of a structured binding must be unique in its declarative region, and was implemented in https://github.com/llvm/llvm-project/commit/bdb84f374cde7736ca68d5db2c2ecf5468346710 .
>From 4b21efb204f8bc0523b162dc22fc490d45cb52f3 Mon Sep 17 00:00:00 2001
From: Yanzuo Liu <zwuis at outlook.com>
Date: Thu, 13 Mar 2025 10:00:37 +0800
Subject: [PATCH] Add test for cwg2289
---
clang/test/CXX/drs/cwg22xx.cpp | 12 ++++++++++++
clang/www/cxx_dr_status.html | 2 +-
2 files changed, 13 insertions(+), 1 deletion(-)
diff --git a/clang/test/CXX/drs/cwg22xx.cpp b/clang/test/CXX/drs/cwg22xx.cpp
index 8c8ad9f7f74ee..e9dd07c8ebf87 100644
--- a/clang/test/CXX/drs/cwg22xx.cpp
+++ b/clang/test/CXX/drs/cwg22xx.cpp
@@ -207,6 +207,18 @@ namespace cwg2285 { // cwg2285: 4
#endif
} // namespace cwg2285
+namespace cwg2289 { // cwg2289: 4
+// Note: Clang 4 implements this DR but it set a wrong value of `__cplusplus`
+#if __cplusplus >= 201703L
+ void test() {
+ struct A { int x; } a; // #cwg2289-A
+ auto &[A] = a;
+ // since-cxx17-error at -1 {{redefinition of 'A'}}
+ // since-cxx17-note@#cwg2289-A {{previous definition is here}}
+ }
+#endif
+} // namespace cwg2289
+
namespace cwg2292 { // cwg2292: 9
#if __cplusplus >= 201103L
template<typename T> using id = T;
diff --git a/clang/www/cxx_dr_status.html b/clang/www/cxx_dr_status.html
index b7888d2365acc..e727d127c4384 100755
--- a/clang/www/cxx_dr_status.html
+++ b/clang/www/cxx_dr_status.html
@@ -13561,7 +13561,7 @@ <h2 id="cxxdr">C++ defect report implementation status</h2>
<td><a href="https://cplusplus.github.io/CWG/issues/2289.html">2289</a></td>
<td>CD5</td>
<td>Uniqueness of structured binding names</td>
- <td class="unknown" align="center">Unknown</td>
+ <td class="full" align="center">Clang 4</td>
</tr>
<tr id="2290">
<td><a href="https://cplusplus.github.io/CWG/issues/2290.html">2290</a></td>
More information about the cfe-commits
mailing list