This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PR c/52952] More precise locations within format strings


On 12 November 2014 15:54, Manuel López-Ibáñez <lopezibanez@gmail.com> wrote:
> On 12 November 2014 15:38, Marek Polacek <polacek@redhat.com> wrote:
>> On Wed, Nov 12, 2014 at 03:35:06PM +0100, Manuel López-Ibáñez wrote:
>>> > ../../libcpp/line-map.c:667:65: error: suggest braces around empty body in an 'if' statement [-Werror=empty-body]
>>>
>>> I just (r217418) bootstrapped this code and it did not produce this
>>> error (or warning).  Could you give more details?
>>
>> Have you tried the bootstrap without checking enabled?
>
> Indeed, the error is due to linemap_assert definition. My patch just
> exposes the bug. This should fix it:

And I think GCC is wrong to wan here. The point of the Wempty-body
warning is to catch things like:

if(a);
  return 2;
return 3;

However,

if(a)
  ;
return 2;

seems intentional. Clang++ does not warn on the latter and it prints
for the former:

warning: if statement has empty body [-Wempty-body]
  if(a);
       ^
note: put the semicolon on a separate line to silence this warning

which seems a nice way to silence the warning instead of ugly { ; }

Cheers,

Manuel.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]