[clang] [Clang][NFC] Add test for CWG2289 "Uniqueness of structured binding names" (PR #131054)
via cfe-commits
cfe-commits at lists.llvm.org
Wed Mar 12 19:24:42 PDT 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang
Author: Yanzuo Liu (zwuis)
<details>
<summary>Changes</summary>
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 .
---
Full diff: https://github.com/llvm/llvm-project/pull/131054.diff
2 Files Affected:
- (modified) clang/test/CXX/drs/cwg22xx.cpp (+12)
- (modified) clang/www/cxx_dr_status.html (+1-1)
``````````diff
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>
``````````
</details>
https://github.com/llvm/llvm-project/pull/131054
More information about the cfe-commits
mailing list