[clang] [Clang] Implement C++26 Attributes for Structured Bindings (P0609R3) (PR #89906)

2024-04-29 Thread via cfe-commits

cor3ntin wrote:

https://github.com/llvm/llvm-project/pull/90495

https://github.com/llvm/llvm-project/pull/89906
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] Implement C++26 Attributes for Structured Bindings (P0609R3) (PR #89906)

2024-04-29 Thread via cfe-commits


@@ -187,7 +187,7 @@ C++2c implementation status
  
   Trivial infinite loops are not Undefined Behavior
   https://wg21.link/P2809R3;>P2809R3 (DR)
-  No
+  Clang 19

cor3ntin wrote:

I'll fix that shortly

https://github.com/llvm/llvm-project/pull/89906
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] Implement C++26 Attributes for Structured Bindings (P0609R3) (PR #89906)

2024-04-29 Thread via cfe-commits


@@ -1115,7 +1115,9 @@ int64_t Decl::getID() const {
 
 const FunctionType *Decl::getFunctionType(bool BlocksToo) const {
   QualType Ty;
-  if (const auto *D = dyn_cast(this))
+  if (const auto *D = dyn_cast(this))

cor3ntin wrote:

I'll fix that shortly

https://github.com/llvm/llvm-project/pull/89906
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] Implement C++26 Attributes for Structured Bindings (P0609R3) (PR #89906)

2024-04-29 Thread via cfe-commits

cor3ntin wrote:

@kstoimenov Looking now

https://github.com/llvm/llvm-project/pull/89906
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] Implement C++26 Attributes for Structured Bindings (P0609R3) (PR #89906)

2024-04-29 Thread Kirill Stoimenov via cfe-commits

kstoimenov wrote:

This is breaking a sanitizer build bot because it is causing a memory leak: 
https://lab.llvm.org/buildbot/#/builders/168/builds/20146. 

@cor3ntin could you please take a look? 

Thanks! 



https://github.com/llvm/llvm-project/pull/89906
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] Implement C++26 Attributes for Structured Bindings (P0609R3) (PR #89906)

2024-04-29 Thread Adrian Vogelsgesang via cfe-commits


@@ -187,7 +187,7 @@ C++2c implementation status
  
   Trivial infinite loops are not Undefined Behavior
   https://wg21.link/P2809R3;>P2809R3 (DR)
-  No
+  Clang 19

vogelsgesang wrote:

the wrong paper was marked as implemented

https://github.com/llvm/llvm-project/pull/89906
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] Implement C++26 Attributes for Structured Bindings (P0609R3) (PR #89906)

2024-04-28 Thread NAKAMURA Takumi via cfe-commits


@@ -1115,7 +1115,9 @@ int64_t Decl::getID() const {
 
 const FunctionType *Decl::getFunctionType(bool BlocksToo) const {
   QualType Ty;
-  if (const auto *D = dyn_cast(this))
+  if (const auto *D = dyn_cast(this))

chapuni wrote:

Seems causes the warning. `[-Wunused-but-set-variable]`

https://github.com/llvm/llvm-project/pull/89906
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] Implement C++26 Attributes for Structured Bindings (P0609R3) (PR #89906)

2024-04-28 Thread via cfe-commits

https://github.com/cor3ntin closed 
https://github.com/llvm/llvm-project/pull/89906
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] Implement C++26 Attributes for Structured Bindings (P0609R3) (PR #89906)

2024-04-28 Thread via cfe-commits

https://github.com/cor3ntin updated 
https://github.com/llvm/llvm-project/pull/89906

>From e87546f2bc0c7d213b6c1f2b414e0ce5335b3e47 Mon Sep 17 00:00:00 2001
From: Corentin Jabot 
Date: Wed, 24 Apr 2024 11:53:28 +0200
Subject: [PATCH 1/5] [Clang] Implement C++26 Attributes for Structured
 Bindings (P0609R3)

https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2024/p0609r3.pdf

We support this feature in all language mode.
maybe_unused applied to a binding makes the whole declaration unused.
There maybe something more clever to do here but that can be explored
as a separate PR.
---
 clang/docs/LanguageExtensions.rst |  1 +
 clang/docs/ReleaseNotes.rst   |  2 +
 clang/include/clang/Basic/Attr.td |  2 +-
 .../clang/Basic/DiagnosticParseKinds.td   | 10 +
 clang/include/clang/Sema/DeclSpec.h   | 10 +++--
 clang/include/clang/Sema/ParsedAttr.h |  1 +
 clang/lib/Frontend/InitPreprocessor.cpp   |  2 +-
 clang/lib/Parse/ParseDecl.cpp | 41 ++-
 clang/lib/Sema/DeclSpec.cpp   |  4 +-
 clang/lib/Sema/SemaDecl.cpp   |  2 +-
 clang/lib/Sema/SemaDeclCXX.cpp|  2 +
 clang/test/Lexer/cxx-features.cpp |  2 +-
 clang/test/Parser/cxx1z-decomposition.cpp | 38 +
 clang/test/SemaCXX/unused.cpp | 12 +-
 clang/www/cxx_status.html |  2 +-
 15 files changed, 101 insertions(+), 30 deletions(-)

diff --git a/clang/docs/LanguageExtensions.rst 
b/clang/docs/LanguageExtensions.rst
index 84fc4dee02fa80..49afd6c7f06bdd 100644
--- a/clang/docs/LanguageExtensions.rst
+++ b/clang/docs/LanguageExtensions.rst
@@ -1493,6 +1493,7 @@ Conditional ``explicit`` 
__cpp_conditional_explicit   C+
 ``if consteval`` __cpp_if_consteval   
C++23 C++20
 ``static operator()``__cpp_static_call_operator   
C++23 C++03
 Attributes on Lambda-Expressions  
C++23 C++11
+Attributes on Structured Bindings__cpp_structured_bindings
C++26 C++03
 ``= delete ("should have a reason");``   __cpp_deleted_function   
C++26 C++03
   
- -
 Designated initializers (N494)
C99   C89
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 64526ed6d06f55..8c8ded8cde0837 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -131,6 +131,8 @@ C++2c Feature Support
 
 - Implemented `P2573R2: = delete("should have a reason"); 
`_
 
+- Implemented `P0609R3: Attributes for Structured Bindings 
`_
+
 
 Resolutions to C++ Defect Reports
 ^
diff --git a/clang/include/clang/Basic/Attr.td 
b/clang/include/clang/Basic/Attr.td
index 4408d517e70e58..97e06fe7d2e6aa 100644
--- a/clang/include/clang/Basic/Attr.td
+++ b/clang/include/clang/Basic/Attr.td
@@ -3211,7 +3211,7 @@ def ObjCRequiresPropertyDefs : InheritableAttr {
 def Unused : InheritableAttr {
   let Spellings = [CXX11<"", "maybe_unused", 201603>, GCC<"unused">,
C23<"", "maybe_unused", 202106>];
-  let Subjects = SubjectList<[Var, ObjCIvar, Type, Enum, EnumConstant, Label,
+  let Subjects = SubjectList<[Var, Binding, ObjCIvar, Type, Enum, 
EnumConstant, Label,
   Field, ObjCMethod, FunctionLike]>;
   let Documentation = [WarnMaybeUnusedDocs];
 }
diff --git a/clang/include/clang/Basic/DiagnosticParseKinds.td 
b/clang/include/clang/Basic/DiagnosticParseKinds.td
index 38174cf3549f14..74ce0f8b53a48c 100644
--- a/clang/include/clang/Basic/DiagnosticParseKinds.td
+++ b/clang/include/clang/Basic/DiagnosticParseKinds.td
@@ -1056,11 +1056,21 @@ def ext_decl_attrs_on_lambda : ExtWarn<
 def ext_lambda_missing_parens : ExtWarn<
   "lambda without a parameter clause is a C++23 extension">,
   InGroup;
+
 def warn_cxx20_compat_decl_attrs_on_lambda : Warning<
   "%select{an attribute specifier sequence|%1}0 in this position "
   "is incompatible with C++ standards before C++23">,
   InGroup, DefaultIgnore;
 
+def ext_decl_attrs_on_binding : ExtWarn<
+  "an attribute specifier sequence attached to a structured binding 
declaration "
+  "is a C++2c extension">, InGroup;
+
+def warn_cxx23_compat_decl_attrs_on_binding : Warning<
+  "an attribute specifier sequence attached to a structured binding 
declaration "
+  "is incompatible with C++ standards before C++2c">,
+  InGroup, DefaultIgnore;
+
 // C++17 lambda expressions
 def err_expected_star_this_capture : Error<
   "expected 'this' following '*' in lambda capture list">;
diff --git a/clang/include/clang/Sema/DeclSpec.h 
b/clang/include/clang/Sema/DeclSpec.h

[clang] [Clang] Implement C++26 Attributes for Structured Bindings (P0609R3) (PR #89906)

2024-04-26 Thread via cfe-commits

https://github.com/cor3ntin updated 
https://github.com/llvm/llvm-project/pull/89906

>From e87546f2bc0c7d213b6c1f2b414e0ce5335b3e47 Mon Sep 17 00:00:00 2001
From: Corentin Jabot 
Date: Wed, 24 Apr 2024 11:53:28 +0200
Subject: [PATCH 1/4] [Clang] Implement C++26 Attributes for Structured
 Bindings (P0609R3)

https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2024/p0609r3.pdf

We support this feature in all language mode.
maybe_unused applied to a binding makes the whole declaration unused.
There maybe something more clever to do here but that can be explored
as a separate PR.
---
 clang/docs/LanguageExtensions.rst |  1 +
 clang/docs/ReleaseNotes.rst   |  2 +
 clang/include/clang/Basic/Attr.td |  2 +-
 .../clang/Basic/DiagnosticParseKinds.td   | 10 +
 clang/include/clang/Sema/DeclSpec.h   | 10 +++--
 clang/include/clang/Sema/ParsedAttr.h |  1 +
 clang/lib/Frontend/InitPreprocessor.cpp   |  2 +-
 clang/lib/Parse/ParseDecl.cpp | 41 ++-
 clang/lib/Sema/DeclSpec.cpp   |  4 +-
 clang/lib/Sema/SemaDecl.cpp   |  2 +-
 clang/lib/Sema/SemaDeclCXX.cpp|  2 +
 clang/test/Lexer/cxx-features.cpp |  2 +-
 clang/test/Parser/cxx1z-decomposition.cpp | 38 +
 clang/test/SemaCXX/unused.cpp | 12 +-
 clang/www/cxx_status.html |  2 +-
 15 files changed, 101 insertions(+), 30 deletions(-)

diff --git a/clang/docs/LanguageExtensions.rst 
b/clang/docs/LanguageExtensions.rst
index 84fc4dee02fa80..49afd6c7f06bdd 100644
--- a/clang/docs/LanguageExtensions.rst
+++ b/clang/docs/LanguageExtensions.rst
@@ -1493,6 +1493,7 @@ Conditional ``explicit`` 
__cpp_conditional_explicit   C+
 ``if consteval`` __cpp_if_consteval   
C++23 C++20
 ``static operator()``__cpp_static_call_operator   
C++23 C++03
 Attributes on Lambda-Expressions  
C++23 C++11
+Attributes on Structured Bindings__cpp_structured_bindings
C++26 C++03
 ``= delete ("should have a reason");``   __cpp_deleted_function   
C++26 C++03
   
- -
 Designated initializers (N494)
C99   C89
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 64526ed6d06f55..8c8ded8cde0837 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -131,6 +131,8 @@ C++2c Feature Support
 
 - Implemented `P2573R2: = delete("should have a reason"); 
`_
 
+- Implemented `P0609R3: Attributes for Structured Bindings 
`_
+
 
 Resolutions to C++ Defect Reports
 ^
diff --git a/clang/include/clang/Basic/Attr.td 
b/clang/include/clang/Basic/Attr.td
index 4408d517e70e58..97e06fe7d2e6aa 100644
--- a/clang/include/clang/Basic/Attr.td
+++ b/clang/include/clang/Basic/Attr.td
@@ -3211,7 +3211,7 @@ def ObjCRequiresPropertyDefs : InheritableAttr {
 def Unused : InheritableAttr {
   let Spellings = [CXX11<"", "maybe_unused", 201603>, GCC<"unused">,
C23<"", "maybe_unused", 202106>];
-  let Subjects = SubjectList<[Var, ObjCIvar, Type, Enum, EnumConstant, Label,
+  let Subjects = SubjectList<[Var, Binding, ObjCIvar, Type, Enum, 
EnumConstant, Label,
   Field, ObjCMethod, FunctionLike]>;
   let Documentation = [WarnMaybeUnusedDocs];
 }
diff --git a/clang/include/clang/Basic/DiagnosticParseKinds.td 
b/clang/include/clang/Basic/DiagnosticParseKinds.td
index 38174cf3549f14..74ce0f8b53a48c 100644
--- a/clang/include/clang/Basic/DiagnosticParseKinds.td
+++ b/clang/include/clang/Basic/DiagnosticParseKinds.td
@@ -1056,11 +1056,21 @@ def ext_decl_attrs_on_lambda : ExtWarn<
 def ext_lambda_missing_parens : ExtWarn<
   "lambda without a parameter clause is a C++23 extension">,
   InGroup;
+
 def warn_cxx20_compat_decl_attrs_on_lambda : Warning<
   "%select{an attribute specifier sequence|%1}0 in this position "
   "is incompatible with C++ standards before C++23">,
   InGroup, DefaultIgnore;
 
+def ext_decl_attrs_on_binding : ExtWarn<
+  "an attribute specifier sequence attached to a structured binding 
declaration "
+  "is a C++2c extension">, InGroup;
+
+def warn_cxx23_compat_decl_attrs_on_binding : Warning<
+  "an attribute specifier sequence attached to a structured binding 
declaration "
+  "is incompatible with C++ standards before C++2c">,
+  InGroup, DefaultIgnore;
+
 // C++17 lambda expressions
 def err_expected_star_this_capture : Error<
   "expected 'this' following '*' in lambda capture list">;
diff --git a/clang/include/clang/Sema/DeclSpec.h 
b/clang/include/clang/Sema/DeclSpec.h

[clang] [Clang] Implement C++26 Attributes for Structured Bindings (P0609R3) (PR #89906)

2024-04-26 Thread via cfe-commits

https://github.com/yronglin approved this pull request.

LGTM!

https://github.com/llvm/llvm-project/pull/89906
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] Implement C++26 Attributes for Structured Bindings (P0609R3) (PR #89906)

2024-04-26 Thread Erich Keane via cfe-commits

https://github.com/erichkeane approved this pull request.


https://github.com/llvm/llvm-project/pull/89906
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] Implement C++26 Attributes for Structured Bindings (P0609R3) (PR #89906)

2024-04-25 Thread via cfe-commits

https://github.com/cor3ntin updated 
https://github.com/llvm/llvm-project/pull/89906

>From e87546f2bc0c7d213b6c1f2b414e0ce5335b3e47 Mon Sep 17 00:00:00 2001
From: Corentin Jabot 
Date: Wed, 24 Apr 2024 11:53:28 +0200
Subject: [PATCH 1/3] [Clang] Implement C++26 Attributes for Structured
 Bindings (P0609R3)

https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2024/p0609r3.pdf

We support this feature in all language mode.
maybe_unused applied to a binding makes the whole declaration unused.
There maybe something more clever to do here but that can be explored
as a separate PR.
---
 clang/docs/LanguageExtensions.rst |  1 +
 clang/docs/ReleaseNotes.rst   |  2 +
 clang/include/clang/Basic/Attr.td |  2 +-
 .../clang/Basic/DiagnosticParseKinds.td   | 10 +
 clang/include/clang/Sema/DeclSpec.h   | 10 +++--
 clang/include/clang/Sema/ParsedAttr.h |  1 +
 clang/lib/Frontend/InitPreprocessor.cpp   |  2 +-
 clang/lib/Parse/ParseDecl.cpp | 41 ++-
 clang/lib/Sema/DeclSpec.cpp   |  4 +-
 clang/lib/Sema/SemaDecl.cpp   |  2 +-
 clang/lib/Sema/SemaDeclCXX.cpp|  2 +
 clang/test/Lexer/cxx-features.cpp |  2 +-
 clang/test/Parser/cxx1z-decomposition.cpp | 38 +
 clang/test/SemaCXX/unused.cpp | 12 +-
 clang/www/cxx_status.html |  2 +-
 15 files changed, 101 insertions(+), 30 deletions(-)

diff --git a/clang/docs/LanguageExtensions.rst 
b/clang/docs/LanguageExtensions.rst
index 84fc4dee02fa80..49afd6c7f06bdd 100644
--- a/clang/docs/LanguageExtensions.rst
+++ b/clang/docs/LanguageExtensions.rst
@@ -1493,6 +1493,7 @@ Conditional ``explicit`` 
__cpp_conditional_explicit   C+
 ``if consteval`` __cpp_if_consteval   
C++23 C++20
 ``static operator()``__cpp_static_call_operator   
C++23 C++03
 Attributes on Lambda-Expressions  
C++23 C++11
+Attributes on Structured Bindings__cpp_structured_bindings
C++26 C++03
 ``= delete ("should have a reason");``   __cpp_deleted_function   
C++26 C++03
   
- -
 Designated initializers (N494)
C99   C89
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 64526ed6d06f55..8c8ded8cde0837 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -131,6 +131,8 @@ C++2c Feature Support
 
 - Implemented `P2573R2: = delete("should have a reason"); 
`_
 
+- Implemented `P0609R3: Attributes for Structured Bindings 
`_
+
 
 Resolutions to C++ Defect Reports
 ^
diff --git a/clang/include/clang/Basic/Attr.td 
b/clang/include/clang/Basic/Attr.td
index 4408d517e70e58..97e06fe7d2e6aa 100644
--- a/clang/include/clang/Basic/Attr.td
+++ b/clang/include/clang/Basic/Attr.td
@@ -3211,7 +3211,7 @@ def ObjCRequiresPropertyDefs : InheritableAttr {
 def Unused : InheritableAttr {
   let Spellings = [CXX11<"", "maybe_unused", 201603>, GCC<"unused">,
C23<"", "maybe_unused", 202106>];
-  let Subjects = SubjectList<[Var, ObjCIvar, Type, Enum, EnumConstant, Label,
+  let Subjects = SubjectList<[Var, Binding, ObjCIvar, Type, Enum, 
EnumConstant, Label,
   Field, ObjCMethod, FunctionLike]>;
   let Documentation = [WarnMaybeUnusedDocs];
 }
diff --git a/clang/include/clang/Basic/DiagnosticParseKinds.td 
b/clang/include/clang/Basic/DiagnosticParseKinds.td
index 38174cf3549f14..74ce0f8b53a48c 100644
--- a/clang/include/clang/Basic/DiagnosticParseKinds.td
+++ b/clang/include/clang/Basic/DiagnosticParseKinds.td
@@ -1056,11 +1056,21 @@ def ext_decl_attrs_on_lambda : ExtWarn<
 def ext_lambda_missing_parens : ExtWarn<
   "lambda without a parameter clause is a C++23 extension">,
   InGroup;
+
 def warn_cxx20_compat_decl_attrs_on_lambda : Warning<
   "%select{an attribute specifier sequence|%1}0 in this position "
   "is incompatible with C++ standards before C++23">,
   InGroup, DefaultIgnore;
 
+def ext_decl_attrs_on_binding : ExtWarn<
+  "an attribute specifier sequence attached to a structured binding 
declaration "
+  "is a C++2c extension">, InGroup;
+
+def warn_cxx23_compat_decl_attrs_on_binding : Warning<
+  "an attribute specifier sequence attached to a structured binding 
declaration "
+  "is incompatible with C++ standards before C++2c">,
+  InGroup, DefaultIgnore;
+
 // C++17 lambda expressions
 def err_expected_star_this_capture : Error<
   "expected 'this' following '*' in lambda capture list">;
diff --git a/clang/include/clang/Sema/DeclSpec.h 
b/clang/include/clang/Sema/DeclSpec.h

[clang] [Clang] Implement C++26 Attributes for Structured Bindings (P0609R3) (PR #89906)

2024-04-25 Thread via cfe-commits


@@ -102,11 +102,21 @@ namespace PR33839 {
 for (auto [x] : a) { // expected-warning {{unused variable '[x]'}}
 }
   }
-  void use() { 
+  void use() {
 f(); // expected-note {{instantiation of}}
 g();
 g();
 h(); // expected-note {{instantiation of}}
   }
 }
+
+namespace maybe_unused_binding {
+
+void test() {
+  struct X { int a, b; } x;
+  auto [a [[maybe_unused]], b] = x; // expected-warning {{an attribute 
specifier sequence attached to a structured binding declaration is a C++2c 
extension}}

yronglin wrote:

Agree!

https://github.com/llvm/llvm-project/pull/89906
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] Implement C++26 Attributes for Structured Bindings (P0609R3) (PR #89906)

2024-04-25 Thread via cfe-commits


@@ -102,11 +102,21 @@ namespace PR33839 {
 for (auto [x] : a) { // expected-warning {{unused variable '[x]'}}
 }
   }
-  void use() { 
+  void use() {
 f(); // expected-note {{instantiation of}}
 g();
 g();
 h(); // expected-note {{instantiation of}}
   }
 }
+
+namespace maybe_unused_binding {
+
+void test() {
+  struct X { int a, b; } x;
+  auto [a [[maybe_unused]], b] = x; // expected-warning {{an attribute 
specifier sequence attached to a structured binding declaration is a C++2c 
extension}}

cor3ntin wrote:

Done
I created an issue to allow the deprecated attribute 
https://github.com/cplusplus/CWG/issues/530 
(We now support that as an extension , and it would be challenging not to)

https://github.com/llvm/llvm-project/pull/89906
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] Implement C++26 Attributes for Structured Bindings (P0609R3) (PR #89906)

2024-04-25 Thread via cfe-commits

https://github.com/cor3ntin updated 
https://github.com/llvm/llvm-project/pull/89906

>From e87546f2bc0c7d213b6c1f2b414e0ce5335b3e47 Mon Sep 17 00:00:00 2001
From: Corentin Jabot 
Date: Wed, 24 Apr 2024 11:53:28 +0200
Subject: [PATCH 1/2] [Clang] Implement C++26 Attributes for Structured
 Bindings (P0609R3)

https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2024/p0609r3.pdf

We support this feature in all language mode.
maybe_unused applied to a binding makes the whole declaration unused.
There maybe something more clever to do here but that can be explored
as a separate PR.
---
 clang/docs/LanguageExtensions.rst |  1 +
 clang/docs/ReleaseNotes.rst   |  2 +
 clang/include/clang/Basic/Attr.td |  2 +-
 .../clang/Basic/DiagnosticParseKinds.td   | 10 +
 clang/include/clang/Sema/DeclSpec.h   | 10 +++--
 clang/include/clang/Sema/ParsedAttr.h |  1 +
 clang/lib/Frontend/InitPreprocessor.cpp   |  2 +-
 clang/lib/Parse/ParseDecl.cpp | 41 ++-
 clang/lib/Sema/DeclSpec.cpp   |  4 +-
 clang/lib/Sema/SemaDecl.cpp   |  2 +-
 clang/lib/Sema/SemaDeclCXX.cpp|  2 +
 clang/test/Lexer/cxx-features.cpp |  2 +-
 clang/test/Parser/cxx1z-decomposition.cpp | 38 +
 clang/test/SemaCXX/unused.cpp | 12 +-
 clang/www/cxx_status.html |  2 +-
 15 files changed, 101 insertions(+), 30 deletions(-)

diff --git a/clang/docs/LanguageExtensions.rst 
b/clang/docs/LanguageExtensions.rst
index 84fc4dee02fa80..49afd6c7f06bdd 100644
--- a/clang/docs/LanguageExtensions.rst
+++ b/clang/docs/LanguageExtensions.rst
@@ -1493,6 +1493,7 @@ Conditional ``explicit`` 
__cpp_conditional_explicit   C+
 ``if consteval`` __cpp_if_consteval   
C++23 C++20
 ``static operator()``__cpp_static_call_operator   
C++23 C++03
 Attributes on Lambda-Expressions  
C++23 C++11
+Attributes on Structured Bindings__cpp_structured_bindings
C++26 C++03
 ``= delete ("should have a reason");``   __cpp_deleted_function   
C++26 C++03
   
- -
 Designated initializers (N494)
C99   C89
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 64526ed6d06f55..8c8ded8cde0837 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -131,6 +131,8 @@ C++2c Feature Support
 
 - Implemented `P2573R2: = delete("should have a reason"); 
`_
 
+- Implemented `P0609R3: Attributes for Structured Bindings 
`_
+
 
 Resolutions to C++ Defect Reports
 ^
diff --git a/clang/include/clang/Basic/Attr.td 
b/clang/include/clang/Basic/Attr.td
index 4408d517e70e58..97e06fe7d2e6aa 100644
--- a/clang/include/clang/Basic/Attr.td
+++ b/clang/include/clang/Basic/Attr.td
@@ -3211,7 +3211,7 @@ def ObjCRequiresPropertyDefs : InheritableAttr {
 def Unused : InheritableAttr {
   let Spellings = [CXX11<"", "maybe_unused", 201603>, GCC<"unused">,
C23<"", "maybe_unused", 202106>];
-  let Subjects = SubjectList<[Var, ObjCIvar, Type, Enum, EnumConstant, Label,
+  let Subjects = SubjectList<[Var, Binding, ObjCIvar, Type, Enum, 
EnumConstant, Label,
   Field, ObjCMethod, FunctionLike]>;
   let Documentation = [WarnMaybeUnusedDocs];
 }
diff --git a/clang/include/clang/Basic/DiagnosticParseKinds.td 
b/clang/include/clang/Basic/DiagnosticParseKinds.td
index 38174cf3549f14..74ce0f8b53a48c 100644
--- a/clang/include/clang/Basic/DiagnosticParseKinds.td
+++ b/clang/include/clang/Basic/DiagnosticParseKinds.td
@@ -1056,11 +1056,21 @@ def ext_decl_attrs_on_lambda : ExtWarn<
 def ext_lambda_missing_parens : ExtWarn<
   "lambda without a parameter clause is a C++23 extension">,
   InGroup;
+
 def warn_cxx20_compat_decl_attrs_on_lambda : Warning<
   "%select{an attribute specifier sequence|%1}0 in this position "
   "is incompatible with C++ standards before C++23">,
   InGroup, DefaultIgnore;
 
+def ext_decl_attrs_on_binding : ExtWarn<
+  "an attribute specifier sequence attached to a structured binding 
declaration "
+  "is a C++2c extension">, InGroup;
+
+def warn_cxx23_compat_decl_attrs_on_binding : Warning<
+  "an attribute specifier sequence attached to a structured binding 
declaration "
+  "is incompatible with C++ standards before C++2c">,
+  InGroup, DefaultIgnore;
+
 // C++17 lambda expressions
 def err_expected_star_this_capture : Error<
   "expected 'this' following '*' in lambda capture list">;
diff --git a/clang/include/clang/Sema/DeclSpec.h 
b/clang/include/clang/Sema/DeclSpec.h

[clang] [Clang] Implement C++26 Attributes for Structured Bindings (P0609R3) (PR #89906)

2024-04-25 Thread via cfe-commits


@@ -102,11 +102,21 @@ namespace PR33839 {
 for (auto [x] : a) { // expected-warning {{unused variable '[x]'}}
 }
   }
-  void use() { 
+  void use() {
 f(); // expected-note {{instantiation of}}
 g();
 g();
 h(); // expected-note {{instantiation of}}
   }
 }
+
+namespace maybe_unused_binding {
+
+void test() {
+  struct X { int a, b; } x;
+  auto [a [[maybe_unused]], b] = x; // expected-warning {{an attribute 
specifier sequence attached to a structured binding declaration is a C++2c 
extension}}

cor3ntin wrote:

> Are there any standard attributes other than this that make sense on SB's? If 
> not, I'd like all of the standards ones tested to show what the behavior is 
> (and 'not valid here' type errors are totally acceptable).

No, I can add tests

> 
> `[[indeterminate]]` seems useful, but the rest should likely result in a 
> rejection.

We do not have this one
> 
> Additionally, we should do an audit of ALL our "C++" spelling attributes to 
> see which make sense here and to make sure they are treated reasonably. I'm 
> not asking to do that HERE, but a bug in our bug tracker (perhaps with a 
> 'good starter bug' tag, particularly if we list ALL our attributes that need 
> auditing) would be acceptable.

Yes, I can create an issue once we land that

https://github.com/llvm/llvm-project/pull/89906
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] Implement C++26 Attributes for Structured Bindings (P0609R3) (PR #89906)

2024-04-25 Thread via cfe-commits


@@ -102,11 +102,21 @@ namespace PR33839 {
 for (auto [x] : a) { // expected-warning {{unused variable '[x]'}}
 }
   }
-  void use() { 
+  void use() {
 f(); // expected-note {{instantiation of}}
 g();
 g();
 h(); // expected-note {{instantiation of}}
   }
 }
+
+namespace maybe_unused_binding {
+
+void test() {
+  struct X { int a, b; } x;
+  auto [a [[maybe_unused]], b] = x; // expected-warning {{an attribute 
specifier sequence attached to a structured binding declaration is a C++2c 
extension}}

cor3ntin wrote:

This is that test.
By marking one of the member unused, we don't warn on any of the member.
This perhaps not perfect but the standard already specified that if one of the 
member is used, we should not warn on any of the biding

https://github.com/llvm/llvm-project/pull/89906
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] Implement C++26 Attributes for Structured Bindings (P0609R3) (PR #89906)

2024-04-25 Thread via cfe-commits


@@ -102,11 +102,21 @@ namespace PR33839 {
 for (auto [x] : a) { // expected-warning {{unused variable '[x]'}}
 }
   }
-  void use() { 
+  void use() {
 f(); // expected-note {{instantiation of}}
 g();
 g();
 h(); // expected-note {{instantiation of}}
   }
 }
+
+namespace maybe_unused_binding {
+
+void test() {
+  struct X { int a, b; } x;
+  auto [a [[maybe_unused]], b] = x; // expected-warning {{an attribute 
specifier sequence attached to a structured binding declaration is a C++2c 
extension}}

yronglin wrote:

Should we add a test to check the `[[maybe_unused]]` takes effect. 
e.g. checks whether there has `warning: unused variable '[a, b]' 
[-Wunused-variable]`.

I've a question about this test case. We only add `[[maybe_unused]]` to `a` , 
IIUC, should we also emit a warning that `unused variable 'b'`?

https://github.com/llvm/llvm-project/pull/89906
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] Implement C++26 Attributes for Structured Bindings (P0609R3) (PR #89906)

2024-04-25 Thread Erich Keane via cfe-commits


@@ -102,11 +102,21 @@ namespace PR33839 {
 for (auto [x] : a) { // expected-warning {{unused variable '[x]'}}
 }
   }
-  void use() { 
+  void use() {
 f(); // expected-note {{instantiation of}}
 g();
 g();
 h(); // expected-note {{instantiation of}}
   }
 }
+
+namespace maybe_unused_binding {
+
+void test() {
+  struct X { int a, b; } x;
+  auto [a [[maybe_unused]], b] = x; // expected-warning {{an attribute 
specifier sequence attached to a structured binding declaration is a C++2c 
extension}}

erichkeane wrote:

Are there any standard attributes other than this that make sense on SB's?  If 
not, I'd like all of the standards ones tested to show what the behavior is 
(and 'not valid here' type errors are totally acceptable).

`[[indeterminate]]` seems useful, but  the rest should likely result in a 
rejection.

Additionally, we should do an audit of ALL our "C++" spelling attributes to see 
which make sense here and to make sure they are treated reasonably.  I'm not 
asking to do that HERE, but a bug in our bug tracker (perhaps with a 'good 
starter bug' tag, particularly if we list ALL our attributes that need 
auditing) would be acceptable.

https://github.com/llvm/llvm-project/pull/89906
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] Implement C++26 Attributes for Structured Bindings (P0609R3) (PR #89906)

2024-04-25 Thread Erich Keane via cfe-commits

erichkeane wrote:

> > Thank you working on this. I'm really like this feature! I've a question, 
> > do we have any further plans to support GNU extension attributes(e.g. 
> > **attribute**((aligned)))? Although it is not included in the paper.
> 
> No, sorry!
> 
> My goal here is to increase conformance, not to invent new extensions. If 
> someone wants to do that work, they would have to motivate the change, do the 
> design leg work and synchronize with GCC. More generally, supporting GNU 
> syntax in relatively new, C++ specific constructs is probably of limited use. 
> If there were attributes useful in structured binding that don't yet have a 
> `[[]]` spelling, we should probably would want to fix that instead.

Agreed 100%.

https://github.com/llvm/llvm-project/pull/89906
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] Implement C++26 Attributes for Structured Bindings (P0609R3) (PR #89906)

2024-04-25 Thread via cfe-commits

cor3ntin wrote:

> Thank you working on this. I'm really like this feature! I've a question, do 
> we have any further plans to support GNU extension attributes(e.g. 
> __attribute__((aligned)))? Although it is not included in the paper.

No, sorry!

My goal here is to increase conformance, not to invent new extensions.
If someone wants to do that work, they would have to motivate the change, do 
the design leg work and synchronize with GCC.
More generally, supporting GNU syntax in relatively new, C++ specific 
constructs is probably of limited use.
If there were attributes useful in structured binding that don't yet have a 
`[[]]` spelling, we should probably would want to fix that instead.


https://github.com/llvm/llvm-project/pull/89906
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] Implement C++26 Attributes for Structured Bindings (P0609R3) (PR #89906)

2024-04-24 Thread via cfe-commits

yronglin wrote:

Thank you working on this. I'd very like this feature! I've a question, do we 
have any further plans to support GNU extension attributes(e.g. 
`__attribute__((aligned))`)? Although it is not included in the paper.

https://github.com/llvm/llvm-project/pull/89906
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] Implement C++26 Attributes for Structured Bindings (P0609R3) (PR #89906)

2024-04-24 Thread via cfe-commits


@@ -1056,11 +1056,21 @@ def ext_decl_attrs_on_lambda : ExtWarn<
 def ext_lambda_missing_parens : ExtWarn<
   "lambda without a parameter clause is a C++23 extension">,
   InGroup;
+

yronglin wrote:

Here is a whitespace change.

https://github.com/llvm/llvm-project/pull/89906
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] Implement C++26 Attributes for Structured Bindings (P0609R3) (PR #89906)

2024-04-24 Thread via cfe-commits


@@ -317,7 +317,7 @@ void Declarator::setDecompositionBindings(
   new DecompositionDeclarator::Binding[Bindings.size()];

cor3ntin wrote:

Note I'm not super fan of the hidden vector implementation here.
It forces Binding to be default constructible.

https://github.com/llvm/llvm-project/pull/89906
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] Implement C++26 Attributes for Structured Bindings (P0609R3) (PR #89906)

2024-04-24 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: cor3ntin (cor3ntin)


Changes

https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2024/p0609r3.pdf

We support this feature in all language mode.
maybe_unused applied to a binding makes the whole declaration unused. There 
maybe something more clever to do here but that can be explored as a separate 
PR.

---
Full diff: https://github.com/llvm/llvm-project/pull/89906.diff


15 Files Affected:

- (modified) clang/docs/LanguageExtensions.rst (+1) 
- (modified) clang/docs/ReleaseNotes.rst (+2) 
- (modified) clang/include/clang/Basic/Attr.td (+1-1) 
- (modified) clang/include/clang/Basic/DiagnosticParseKinds.td (+10) 
- (modified) clang/include/clang/Sema/DeclSpec.h (+6-4) 
- (modified) clang/include/clang/Sema/ParsedAttr.h (+1) 
- (modified) clang/lib/Frontend/InitPreprocessor.cpp (+1-1) 
- (modified) clang/lib/Parse/ParseDecl.cpp (+31-10) 
- (modified) clang/lib/Sema/DeclSpec.cpp (+2-2) 
- (modified) clang/lib/Sema/SemaDecl.cpp (+1-1) 
- (modified) clang/lib/Sema/SemaDeclCXX.cpp (+2) 
- (modified) clang/test/Lexer/cxx-features.cpp (+1-1) 
- (modified) clang/test/Parser/cxx1z-decomposition.cpp (+30-8) 
- (modified) clang/test/SemaCXX/unused.cpp (+11-1) 
- (modified) clang/www/cxx_status.html (+1-1) 


``diff
diff --git a/clang/docs/LanguageExtensions.rst 
b/clang/docs/LanguageExtensions.rst
index 84fc4dee02fa80..49afd6c7f06bdd 100644
--- a/clang/docs/LanguageExtensions.rst
+++ b/clang/docs/LanguageExtensions.rst
@@ -1493,6 +1493,7 @@ Conditional ``explicit`` 
__cpp_conditional_explicit   C+
 ``if consteval`` __cpp_if_consteval   
C++23 C++20
 ``static operator()``__cpp_static_call_operator   
C++23 C++03
 Attributes on Lambda-Expressions  
C++23 C++11
+Attributes on Structured Bindings__cpp_structured_bindings
C++26 C++03
 ``= delete ("should have a reason");``   __cpp_deleted_function   
C++26 C++03
   
- -
 Designated initializers (N494)
C99   C89
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 64526ed6d06f55..8c8ded8cde0837 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -131,6 +131,8 @@ C++2c Feature Support
 
 - Implemented `P2573R2: = delete("should have a reason"); 
`_
 
+- Implemented `P0609R3: Attributes for Structured Bindings 
`_
+
 
 Resolutions to C++ Defect Reports
 ^
diff --git a/clang/include/clang/Basic/Attr.td 
b/clang/include/clang/Basic/Attr.td
index 4408d517e70e58..97e06fe7d2e6aa 100644
--- a/clang/include/clang/Basic/Attr.td
+++ b/clang/include/clang/Basic/Attr.td
@@ -3211,7 +3211,7 @@ def ObjCRequiresPropertyDefs : InheritableAttr {
 def Unused : InheritableAttr {
   let Spellings = [CXX11<"", "maybe_unused", 201603>, GCC<"unused">,
C23<"", "maybe_unused", 202106>];
-  let Subjects = SubjectList<[Var, ObjCIvar, Type, Enum, EnumConstant, Label,
+  let Subjects = SubjectList<[Var, Binding, ObjCIvar, Type, Enum, 
EnumConstant, Label,
   Field, ObjCMethod, FunctionLike]>;
   let Documentation = [WarnMaybeUnusedDocs];
 }
diff --git a/clang/include/clang/Basic/DiagnosticParseKinds.td 
b/clang/include/clang/Basic/DiagnosticParseKinds.td
index 38174cf3549f14..74ce0f8b53a48c 100644
--- a/clang/include/clang/Basic/DiagnosticParseKinds.td
+++ b/clang/include/clang/Basic/DiagnosticParseKinds.td
@@ -1056,11 +1056,21 @@ def ext_decl_attrs_on_lambda : ExtWarn<
 def ext_lambda_missing_parens : ExtWarn<
   "lambda without a parameter clause is a C++23 extension">,
   InGroup;
+
 def warn_cxx20_compat_decl_attrs_on_lambda : Warning<
   "%select{an attribute specifier sequence|%1}0 in this position "
   "is incompatible with C++ standards before C++23">,
   InGroup, DefaultIgnore;
 
+def ext_decl_attrs_on_binding : ExtWarn<
+  "an attribute specifier sequence attached to a structured binding 
declaration "
+  "is a C++2c extension">, InGroup;
+
+def warn_cxx23_compat_decl_attrs_on_binding : Warning<
+  "an attribute specifier sequence attached to a structured binding 
declaration "
+  "is incompatible with C++ standards before C++2c">,
+  InGroup, DefaultIgnore;
+
 // C++17 lambda expressions
 def err_expected_star_this_capture : Error<
   "expected 'this' following '*' in lambda capture list">;
diff --git a/clang/include/clang/Sema/DeclSpec.h 
b/clang/include/clang/Sema/DeclSpec.h
index c9eecdafe62c7c..760c7980be52bd 100644
--- a/clang/include/clang/Sema/DeclSpec.h
+++ b/clang/include/clang/Sema/DeclSpec.h
@@ -36,6 +36,7 @@
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/Support/Compiler.h"

[clang] [Clang] Implement C++26 Attributes for Structured Bindings (P0609R3) (PR #89906)

2024-04-24 Thread via cfe-commits

https://github.com/cor3ntin created 
https://github.com/llvm/llvm-project/pull/89906

https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2024/p0609r3.pdf

We support this feature in all language mode.
maybe_unused applied to a binding makes the whole declaration unused. There 
maybe something more clever to do here but that can be explored as a separate 
PR.

>From e87546f2bc0c7d213b6c1f2b414e0ce5335b3e47 Mon Sep 17 00:00:00 2001
From: Corentin Jabot 
Date: Wed, 24 Apr 2024 11:53:28 +0200
Subject: [PATCH] [Clang] Implement C++26 Attributes for Structured Bindings
 (P0609R3)

https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2024/p0609r3.pdf

We support this feature in all language mode.
maybe_unused applied to a binding makes the whole declaration unused.
There maybe something more clever to do here but that can be explored
as a separate PR.
---
 clang/docs/LanguageExtensions.rst |  1 +
 clang/docs/ReleaseNotes.rst   |  2 +
 clang/include/clang/Basic/Attr.td |  2 +-
 .../clang/Basic/DiagnosticParseKinds.td   | 10 +
 clang/include/clang/Sema/DeclSpec.h   | 10 +++--
 clang/include/clang/Sema/ParsedAttr.h |  1 +
 clang/lib/Frontend/InitPreprocessor.cpp   |  2 +-
 clang/lib/Parse/ParseDecl.cpp | 41 ++-
 clang/lib/Sema/DeclSpec.cpp   |  4 +-
 clang/lib/Sema/SemaDecl.cpp   |  2 +-
 clang/lib/Sema/SemaDeclCXX.cpp|  2 +
 clang/test/Lexer/cxx-features.cpp |  2 +-
 clang/test/Parser/cxx1z-decomposition.cpp | 38 +
 clang/test/SemaCXX/unused.cpp | 12 +-
 clang/www/cxx_status.html |  2 +-
 15 files changed, 101 insertions(+), 30 deletions(-)

diff --git a/clang/docs/LanguageExtensions.rst 
b/clang/docs/LanguageExtensions.rst
index 84fc4dee02fa80..49afd6c7f06bdd 100644
--- a/clang/docs/LanguageExtensions.rst
+++ b/clang/docs/LanguageExtensions.rst
@@ -1493,6 +1493,7 @@ Conditional ``explicit`` 
__cpp_conditional_explicit   C+
 ``if consteval`` __cpp_if_consteval   
C++23 C++20
 ``static operator()``__cpp_static_call_operator   
C++23 C++03
 Attributes on Lambda-Expressions  
C++23 C++11
+Attributes on Structured Bindings__cpp_structured_bindings
C++26 C++03
 ``= delete ("should have a reason");``   __cpp_deleted_function   
C++26 C++03
   
- -
 Designated initializers (N494)
C99   C89
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 64526ed6d06f55..8c8ded8cde0837 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -131,6 +131,8 @@ C++2c Feature Support
 
 - Implemented `P2573R2: = delete("should have a reason"); 
`_
 
+- Implemented `P0609R3: Attributes for Structured Bindings 
`_
+
 
 Resolutions to C++ Defect Reports
 ^
diff --git a/clang/include/clang/Basic/Attr.td 
b/clang/include/clang/Basic/Attr.td
index 4408d517e70e58..97e06fe7d2e6aa 100644
--- a/clang/include/clang/Basic/Attr.td
+++ b/clang/include/clang/Basic/Attr.td
@@ -3211,7 +3211,7 @@ def ObjCRequiresPropertyDefs : InheritableAttr {
 def Unused : InheritableAttr {
   let Spellings = [CXX11<"", "maybe_unused", 201603>, GCC<"unused">,
C23<"", "maybe_unused", 202106>];
-  let Subjects = SubjectList<[Var, ObjCIvar, Type, Enum, EnumConstant, Label,
+  let Subjects = SubjectList<[Var, Binding, ObjCIvar, Type, Enum, 
EnumConstant, Label,
   Field, ObjCMethod, FunctionLike]>;
   let Documentation = [WarnMaybeUnusedDocs];
 }
diff --git a/clang/include/clang/Basic/DiagnosticParseKinds.td 
b/clang/include/clang/Basic/DiagnosticParseKinds.td
index 38174cf3549f14..74ce0f8b53a48c 100644
--- a/clang/include/clang/Basic/DiagnosticParseKinds.td
+++ b/clang/include/clang/Basic/DiagnosticParseKinds.td
@@ -1056,11 +1056,21 @@ def ext_decl_attrs_on_lambda : ExtWarn<
 def ext_lambda_missing_parens : ExtWarn<
   "lambda without a parameter clause is a C++23 extension">,
   InGroup;
+
 def warn_cxx20_compat_decl_attrs_on_lambda : Warning<
   "%select{an attribute specifier sequence|%1}0 in this position "
   "is incompatible with C++ standards before C++23">,
   InGroup, DefaultIgnore;
 
+def ext_decl_attrs_on_binding : ExtWarn<
+  "an attribute specifier sequence attached to a structured binding 
declaration "
+  "is a C++2c extension">, InGroup;
+
+def warn_cxx23_compat_decl_attrs_on_binding : Warning<
+  "an attribute specifier sequence attached to a structured binding 
declaration "
+  "is incompatible with C++