This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] C/C++: add fix-it hints for various missing symbols
- From: David Malcolm <dmalcolm at redhat dot com>
- To: Joseph Myers <joseph at codesourcery dot com>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Wed, 05 Jul 2017 11:32:15 -0400
- Subject: Re: [PATCH] C/C++: add fix-it hints for various missing symbols
- Authentication-results: sourceware.org; auth=none
- Authentication-results: ext-mx05.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com
- Authentication-results: ext-mx05.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=dmalcolm at redhat dot com
- Dkim-filter: OpenDKIM Filter v2.11.0 mx1.redhat.com D7207334586
- Dmarc-filter: OpenDMARC Filter v1.3.2 mx1.redhat.com D7207334586
- References: <1499107059-28855-1-git-send-email-dmalcolm@redhat.com> <alpine.DEB.2.20.1707032300480.4080@digraph.polyomino.org.uk>
On Mon, 2017-07-03 at 23:01 +0000, Joseph Myers wrote:
> Does the changed location fix bug 7356?
The patch as-written doesn't affect that bug, since the patch only
affects sites that use c_parser_require and cp_parser_require with
certain token types, and the diagnostic in PR 7356 is emitted by the C
FE here:
2174 /* This can appear in many cases looking nothing like a
2175 function definition, so we don't give a more specific
2176 error suggesting there was one. */
2177 c_parser_error (parser, "expected %<=%>, %<,%>, %<;%>, %<asm%> "
2178 "or %<__attribute__%>");
(the C++ FE handles it, emitting:
pr7356.c:1:1: error: ‘a’ does not name a type
a//sample
^
)
c_parser_error currently uses the location of the next token, and
concats as description of the next token.
I tried hacking up c_parser_error to unconditionally attempt to use the
location immediately after the previous token. This "fixes" PR 7356,
giving:
pr7356.c:1:2: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘typedef’
a//sample
^
This error message might be better to be worded in terms of the
syntactic thing that came before, which would yield:
pr7356.c:1:2: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’
after declaration
a//sample
^
or somesuch. Doing so would presumably require adding an extra param to
c_parser_error, e.g. an enum describing the syntactic elements that go before.
Does this sound worth pursuing as a followup?
Thanks
Dave