On Thu, Apr 12, 2012 at 12:01 PM, Jonathan Wakely <jwakely....@gmail.com> wrote:
> On 11 April 2012 19:41, Pedro Alves wrote:
>> On 04/11/2012 07:26 PM, Jonathan Wakely wrote:
>>
>>> GCC's diagnostics have got a lot better recently.
>>>
>>> The http://clang.llvm.org/diagnostics.html page compares clang's
>>> diagnostics to GCC 4.2, which was outdated long before that page was
>>> written.
>>>
>>> It doesn't help GCC's cause when people keep repeating that outdated info 
>>> :-)
>>
>>
>> Spelling out the obvious, IWBVN if someone from the gcc camp did a
>> similar comparison using a current gcc.  Is there such a page somewhere?
>
> Manu has filed lots of bugs in bugzilla with specific comparisons of
> GCC's diagnostics to Clang's.
>
> I'll start a page on the GCC wiki but I hope others will add to it.
> The people asking to see results should be the ones doing the
> comparisons really  ;-)
>
> For now, the first example on the clang page now shows GCC is better,
> because it warns about *both* missing arguments, while Clang only gets
> one (even in the unreleased 3.1 version from svn)
>
> $ gcc-4.7 -fsyntax-only  -Wformat format-strings.c
> format-strings.c: In function 'f':
> format-strings.c:4:5: warning: field precision specifier '.*' expects
> a matching 'int' argument [-Wformat]
> format-strings.c:4:5: warning: format '%d' expects a matching 'int'
> argument [-Wformat]
>
> $ clang-3.1 -fsyntax-only format-strings.c
> format-strings.c:4:15: warning: '.*' specified field precision is
> missing a matching 'int' argument
>    printf("%.*d");
>            ~~^~
> 1 warning generated.
>
> Using this source:
>
>
> #include <stdio.h>
>
> void f() {
>    printf("%.*d");
> }
>
>
> And the last example on the page now gives:
>
> $ g++-4.7 tsc.cc
> tsc.cc:2:10: error: expected ';' after class definition
> tsc.cc:6:1: error: expected ';' after struct definition
> $ clang++-3.1 tsc.cc
> tsc.cc:2:11: error: expected ';' after class
> class a {}
>          ^
>          ;
> tsc.cc:6:2: error: expected ';' after struct
> }
>  ^
>  ;
> 2 errors generated.
>
> Which was using this source:
>
> template<class T>
> class a {}
> class temp {};
> a<temp> b;
> struct b {
> }

And since yesterday GCC shows

t.C:2:10: error: expected ';' after class definition
 class a {}
          ^
t.C:6:1: error: expected ';' after struct definition
 }
 ^

as we now enabled -fdiagnostics-show-caret by default.

Richard.

Reply via email to