On Sun, Sep 13, 2015 at 02:50:53PM +0200, Manuel López-Ibáñez wrote: > On 13/09/15 13:40, Mark Wielaard wrote: > >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? Yes, I can. See simplified patch attached. I wasn't aware there was already such a nice framework for this. Thanks, Mark