This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH v2] New C++ warning option '-Waccess-specifiers'
On 23 Jul, Eric Gallager wrote:
> On 7/23/17, Volker Reichelt <v.reichelt@netcologne.de> wrote:
>> Hi again,
>>
>> here is an updated patch for a new warning about redundant
>> access-specifiers. It takes Dave's various comments into account.
>>
>> The main changes w.r.t. to the previous versions are:
>>
>> * The warning is now a two-level warning with a slightly shorter name:
>> -Waccess-specifiers=1, -Waccess-specifiers=2
>> with -Waccess-specifiers defaulting to -Waccess-specifiers=1.
>
> Just a more generalized comment as a user, but I don't really like
> this trend that new warning options are so often given numeric levels
> these days. A warning option with different levels requires special
> handling in configure scripts or Makefiles, which is harder than just
> toggling different names (i.e. how things work without numeric
> levels).
Fair point.
>> * The warning now checks for 3 different scenarios, see testcase
>> Waccess-specifiers-2.C below:
>> A) Two consecutive access-specifiers, so that the first one
>> has no effect. (This is new.)
>> B) Two (non-consecutive) equal access-specifiers.
>> (That's what the original patch checked.)
>> C) An access-specifier that does not change the class-type's default.
>> (That's what I only suggested in the original patch.)
>> The first two tests are enabled in level 1, the last in level 2.
>
> Instead of levels, I'd prefer A and B to be in an option like the
> original -Wduplicate-access-specifiers, while putting C under a
> separate name like -Wdefault-access-specifiers. This way they can be
> toggled individually, so for example I can get just warning C without
> also getting warnings A and B. Using numeric levels makes that
> impossible. But that's just my personal preference for how to separate
> them, so feel free to disregard me.
What I like about the numeric levels is that they are easier to
remember. You don't have to look up different names.
OTOH, toggling on C without A+B might really make sense here.
But I'd like to get some more opinions before I change that.
Regards,
Volker