[clang] [Clang] emit -Wunused-variable warning for unused structured bindings without the [[maybe_unused]] attribute (PR #127061)

Oleksandr T. via cfe-commits cfe-commits at lists.llvm.org
Thu Feb 13 08:22:46 PST 2025


================
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++2c -Wunused %s
+
+namespace GH125810 {
+struct S {
+  int a, b;
+};
+
+void t(S s) {
+  auto &[_, _] = s;
+  auto &[a1, _] = s; // expected-warning {{unused variable '[a1, _]'}}
----------------
a-tarasyuk wrote:

@cor3ntin @AaronBallman Currently, https://godbolt.org/z/911KjMjPY the entire binding declaration is used as the diagnostic location, including all binding elements, even when only some of them are actually unused. Is this the expected behavior?

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


More information about the cfe-commits mailing list