[cfe-commits] [Patch] Add warning for semi-colon after class function definition

David Blaikie dblaikie at gmail.com
Mon Feb 13 15:13:33 PST 2012


On Mon, Feb 13, 2012 at 2:37 PM, Richard Trieu <rtrieu at google.com> wrote:
> On Mon, Feb 13, 2012 at 1:59 PM, David Blaikie <dblaikie at gmail.com> wrote:
>>
>> On Mon, Feb 13, 2012 at 1:52 PM, Richard Trieu <rtrieu at google.com> wrote:
>> > On Mon, Jan 30, 2012 at 10:40 AM, Richard Trieu <rtrieu at google.com>
>> > wrote:
>> >>
>> >> On Wed, Jan 25, 2012 at 5:24 PM, Richard Trieu <rtrieu at google.com>
>> >> wrote:
>> >>>
>> >>> This patch adds a warning to catch semi-colons after function
>> >>> definitions.  The motivation of removing extraneous semi-colons is to
>> >>> make
>> >>> it easier to see which scopes are being ended by a brace.  Function
>> >>> scopes
>> >>> will end with a plain brace.  Class scopes will end with brace and
>> >>> semi-colon.
>> >>>
>> >>> class C {
>> >>>   void F() {};
>> >>> };
>> >>>
>> >>> extra-semi.cc:2:14: warning: extra ';' after function definition
>> >>> [-Wextra-semi]
>> >>>   void F() {};
>> >>>              ^
>> >>> 1 warning generated.
>> >>
>> >>
>> >> Ping.
>> >
>> > Ping.
>>
>> Not to derail this review - but just out of curiosity: do we have a
>> more general 'unnecessary ;' warning? or could we make a general one
>> that covers all cases where ';' is just redudndant & suggests a
>> removal?
>
> There's a few in the parse diagnostics.  They are:
>
> ext_top_level_semi
> warn_cxx98_compat_top_level_semi
> ext_extra_struct_semi
> ext_extra_ivar_semi
>
> warn_cxx98_compat_top_level_semi is a warning that is in a diagnostic group
> so it must be left separate.  The other 3 are Extensions and could probably
> be folded in with my diagnostic if I switched mine to Extension as well and
> added a select into the message.


Oh, sorry - I wasn't so much concerned with the diagnostic text, as
the logic - is there some way we could, in a relatively
universal/general way, catch all/most unnecessary semicolons rather
than adding it on a case-by-case basis like this?




More information about the cfe-commits mailing list