This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH 2/4] PR c++/62314: add fixit hint for "expected ';' after class definition"
- From: David Malcolm <dmalcolm at redhat dot com>
- To: Bernd Schmidt <bschmidt at redhat dot com>, gcc-patches at gcc dot gnu dot org
- Date: Fri, 01 Jul 2016 13:40:20 -0400
- Subject: Re: [PATCH 2/4] PR c++/62314: add fixit hint for "expected ';' after class definition"
- Authentication-results: sourceware.org; auth=none
- References: <1461853698-43954-1-git-send-email-dmalcolm at redhat dot com> <1461853698-43954-2-git-send-email-dmalcolm at redhat dot com> <57272E9B dot 2000404 at redhat dot com>
On Mon, 2016-05-02 at 12:40 +0200, Bernd Schmidt wrote:
> On 04/28/2016 04:28 PM, David Malcolm wrote:
> > whereas clang reportedly emits:
> >
> > test.c:2:12: error: expected ';' after struct
> > struct a {}
> > ^
> > ;
> >
> > (note the offset of the location, and the fix-it hint)
> >
> > The following patch gives us the latter, more readable output.
>
> Huh. Only the non-C++ parts remain to be reviewed, and I have no
> technical objections, but do people really want this? To me that
> looks
> like unnecessary visual clutter that eats up vertical space for no
> reason. I know what a semicolon looks like without the compiler
> telling
> me twice.
My own opinion is that it's worth spending the extra line to get the
semicolon under the caret, as (IMHO) it makes things slightly clearer.
A better argument is that as of r237712 we now have -fdiagnostics
-parseable-fixits. This allows for an IDE to offer to automatically
apply a fix-it hint. Hence by providing a fix-it here, an IDE can
potentially insert the semicolon itself:
$ ./xgcc -B. ../../src/gcc/testsuite/g++.dg/pr62314-2.C \
-fdiagnostics-parseable-fixits
../../src/gcc/testsuite/g++.dg/pr62314-2.C:4:11: error: expected â;â after class definition
class a {} // { dg-error "11: expected .;. after class definition" }
^
;
fix-it:"../../src/gcc/testsuite/g++.dg/pr62314-2.C":{4:11-4:11}:";"
../../src/gcc/testsuite/g++.dg/pr62314-2.C:8:2: error: expected â;â after struct definition
} // { dg-error "2: expected .;. after struct definition" }
^
;
fix-it:"../../src/gcc/testsuite/g++.dg/pr62314-2.C":{8:2-8:2}:";"
I believe that on building this within a sufficiently recent version of
Xcode that Xcode can offer to insert the semicolon directly.
I'm hoping someone implements this for Emacs.
In that light, is the patch OK?
Thanks
Dave