https://github.com/zwuis commented:
> > Personally I want to name this check `modernize-unused-variables` to support
> >
> > * adding `[[maybe_unused]]` instead of renaming the variable to `_`
> > (controlled by an option)
> > * 'simple' variables
> >
> > in future.
> >
> > But, I want fixits to add `[[maybe_unused]]` by default, because
> > `[[maybe_unused]]` is introduced earlier and it works with `assert`, so I'd
> > like to keep this name and make it an alias in future. (changing default
> > fixits is a kind of breaking changes to me)
>
> Do you imagine this case?
>
> ```cpp
> struct Pair {
> int first;
> bool second;
> };
>
> void referenceBinding() {
> Pair p{};
> auto &[x, y [[maybe_unused]] ] = p;
> use(x);
> }
> ```
>
> It gives the following so we still have to emit only in C++26 mode (or I'm
> missing something):
>
> ```
> <source>:16:15: warning: an attribute specifier sequence attached to a
> structured binding declaration is a C++2c extension [-Wc++26-extensions]
> 16 | auto &[x, y [[maybe_unused]] ] = p;
> |
> ```
>
> https://godbolt.org/z/13685qc37
Oh I didn't make it clear. I meant
```cpp
int x = foo();
(void)x;
// fixit 1
int x [[maybe_unused]] = foo();
// vs
// fixit 2
int _ = foo();
```
https://github.com/llvm/llvm-project/pull/207604
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits