[clang] [Clang] Implement C++26 Attributes for Structured Bindings (P0609R3) (PR #89906)
via cfe-commits
cfe-commits at lists.llvm.org
Thu Apr 25 07:18:50 PDT 2024
================
@@ -102,11 +102,21 @@ namespace PR33839 {
for (auto [x] : a) { // expected-warning {{unused variable '[x]'}}
}
}
- void use() {
+ void use() {
f<int>(); // expected-note {{instantiation of}}
g<true>();
g<false>();
h<int>(); // 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
More information about the cfe-commits
mailing list