On 13/09/15 13:40, Mark Wielaard wrote:
On Sun, Sep 13, 2015 at 12:00:51AM +0200, Mark Wielaard wrote:
I'll rewrite my patch a little, add some C++ testcases, and update the
documentation. Then we can discuss again.
Slightly adjusted patch attached. Now it is explicit that the warning is
enabled by -Wunused-variable for C, but not C++. There are testcases for
both C and C++ to check the defaults. And the hardcoded override is
removed for C++, so the user could enable it if they want.
+ /* -Wunused-variable implies -Wunused-const-variable for C, but not
+ for C++, because const variables take the place of #defines in C++. */
+ if (warn_unused_const_variable_set == -1)
+ warn_unused_const_variable_set = (warn_unused_variable
+ && ! c_dialect_cxx ());
+
Can't you use LangEnabledBy() in c.opt to implement this? If not, I think this
would be a regression or a bug.
Ideally, all options dependences should be encoded in the .opt files, however,
it cannot handle yet conditions such as (cxx_dialect >= cxx11 || flag_isoc99).
But it can handle a lot of other things already. See
https://gcc.gnu.org/onlinedocs/gccint/Option-properties.html
Cheers,
Manuel.