There is [[maybe_unused]]
attribute in C++17. It’s implemented in GCC 7, see C++ Standards Support in GCC .
Example from P0212R1 proposal:
[[maybe_unused]] void f([[maybe_unused]] bool thing1,
[[maybe_unused]] bool thing2) {
[[maybe_unused]] bool b = thing1 && thing2;
assert(b);
}