[clang] [Clang] Fix -Wunused-private-field false negative with defaulted comparison operators (PR #116871)

Erich Keane via cfe-commits cfe-commits at lists.llvm.org
Tue Dec 10 06:55:40 PST 2024


erichkeane wrote:

> There are a few ways around this: if you are using c++17 or later, there is `[[maybe_unused]]`. Another option is to ignore this warning in a specific region with:
> 
> ```c++
> #pragma clang diagnostic push
> #pragma clang diagnostic ignored "-Wunused-private-field"
> // your code for which the warning gets suppressed 
> #pragma clang diagnostic pop
> // not suppressed here
> ```

Note you can also spell the standard attribute as `__attribute__((unused))` in boht GCC and Clang.

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


More information about the cfe-commits mailing list