https://github.com/zwuis updated https://github.com/llvm/llvm-project/pull/126421
>From 92c075ab44bd85550fb3f63c36bd67d41821f385 Mon Sep 17 00:00:00 2001 From: Yanzuo Liu <zw...@outlook.com> Date: Mon, 10 Feb 2025 00:34:51 +0800 Subject: [PATCH 1/2] Add test for cwg2285 --- clang/lib/Sema/SemaDeclCXX.cpp | 7 +++++-- clang/test/CXX/drs/cwg22xx.cpp | 18 ++++++++++++++---- clang/www/cxx_dr_status.html | 2 +- 3 files changed, 20 insertions(+), 7 deletions(-) diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp index 0cf02fe6407c24c..7cc67598e4c819f 100644 --- a/clang/lib/Sema/SemaDeclCXX.cpp +++ b/clang/lib/Sema/SemaDeclCXX.cpp @@ -733,8 +733,11 @@ Sema::ActOnDecompositionDeclarator(Scope *S, Declarator &D, } if (!TemplateParamLists.empty()) { - // FIXME: There's no rule against this, but there are also no rules that - // would actually make it usable, so we reject it for now. + // C++17 [temp]/1: + // A template defines a family of class, functions, or variables, or an + // alias for a family of types. + // + // Structured bindings are not included. Diag(TemplateParamLists.front()->getTemplateLoc(), diag::err_decomp_decl_template); return nullptr; diff --git a/clang/test/CXX/drs/cwg22xx.cpp b/clang/test/CXX/drs/cwg22xx.cpp index d93070ef3804dd9..62988e35b963741 100644 --- a/clang/test/CXX/drs/cwg22xx.cpp +++ b/clang/test/CXX/drs/cwg22xx.cpp @@ -1,10 +1,10 @@ // RUN: %clang_cc1 -std=c++98 -triple x86_64-unknown-unknown %s -verify=expected -fexceptions -fcxx-exceptions -pedantic-errors // RUN: %clang_cc1 -std=c++11 -triple x86_64-unknown-unknown %s -verify=expected,since-cxx11 -fexceptions -fcxx-exceptions -pedantic-errors // RUN: %clang_cc1 -std=c++14 -triple x86_64-unknown-unknown %s -verify=expected,since-cxx11 -fexceptions -fcxx-exceptions -pedantic-errors -// RUN: %clang_cc1 -std=c++17 -triple x86_64-unknown-unknown %s -verify=expected,since-cxx11 -fexceptions -fcxx-exceptions -pedantic-errors -// RUN: %clang_cc1 -std=c++20 -triple x86_64-unknown-unknown %s -verify=expected,since-cxx11 -fexceptions -fcxx-exceptions -pedantic-errors -// RUN: %clang_cc1 -std=c++23 -triple x86_64-unknown-unknown %s -verify=expected,since-cxx11 -fexceptions -fcxx-exceptions -pedantic-errors -// RUN: %clang_cc1 -std=c++2c -triple x86_64-unknown-unknown %s -verify=expected,since-cxx11 -fexceptions -fcxx-exceptions -pedantic-errors +// RUN: %clang_cc1 -std=c++17 -triple x86_64-unknown-unknown %s -verify=expected,since-cxx11,since-cxx17 -fexceptions -fcxx-exceptions -pedantic-errors +// RUN: %clang_cc1 -std=c++20 -triple x86_64-unknown-unknown %s -verify=expected,since-cxx11,since-cxx17 -fexceptions -fcxx-exceptions -pedantic-errors +// RUN: %clang_cc1 -std=c++23 -triple x86_64-unknown-unknown %s -verify=expected,since-cxx11,since-cxx17 -fexceptions -fcxx-exceptions -pedantic-errors +// RUN: %clang_cc1 -std=c++2c -triple x86_64-unknown-unknown %s -verify=expected,since-cxx11,since-cxx17 -fexceptions -fcxx-exceptions -pedantic-errors namespace cwg2211 { // cwg2211: 8 @@ -196,6 +196,16 @@ void g() { #endif } // namespace cwg2277 +namespace cwg2285 { // cwg2285: 4 +#if __cplusplus >= 201703L + void test() { + using T = int[1]; + auto [a] = T{a}; + // since-cxx17-error@-1 {{binding 'a' cannot appear in the initializer of its own decomposition declaration}} + } +#endif +} // namespace cwg2285 + 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 69ddd5e58b921a8..3fae1c6c6a0620d 100755 --- a/clang/www/cxx_dr_status.html +++ b/clang/www/cxx_dr_status.html @@ -13537,7 +13537,7 @@ <h2 id="cxxdr">C++ defect report implementation status</h2> <td><a href="https://cplusplus.github.io/CWG/issues/2285.html">2285</a></td> <td>CD5</td> <td>Issues with structured bindings</td> - <td class="unknown" align="center">Unknown</td> + <td class="full" align="center">Clang 4</td> </tr> <tr id="2286"> <td><a href="https://cplusplus.github.io/CWG/issues/2286.html">2286</a></td> >From 17f8c3b237e57463aa6a25b4876b1a75fec6481a Mon Sep 17 00:00:00 2001 From: Yanzuo Liu <zw...@outlook.com> Date: Mon, 10 Feb 2025 20:02:54 +0800 Subject: [PATCH 2/2] Modify comment mentioned in cwg2285 --- clang/test/Parser/cxx1z-decomposition.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clang/test/Parser/cxx1z-decomposition.cpp b/clang/test/Parser/cxx1z-decomposition.cpp index acf3f99069185bc..2b65e77fcd42ce6 100644 --- a/clang/test/Parser/cxx1z-decomposition.cpp +++ b/clang/test/Parser/cxx1z-decomposition.cpp @@ -136,7 +136,7 @@ namespace MultiDeclarator { namespace Template { int n[3]; - // FIXME: There's no actual rule against this... + // Structured binding template is not allowed. template<typename T> auto [a, b, c] = n; // expected-error {{decomposition declaration template not supported}} } _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits