This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH 02/02] C FE: add fix-it hint for . vs ->
- From: Joseph Myers <joseph at codesourcery dot com>
- To: David Malcolm <dmalcolm at redhat dot com>
- Cc: <gcc-patches at gcc dot gnu dot org>
- Date: Tue, 10 Nov 2015 17:55:18 +0000
- Subject: Re: [PATCH 02/02] C FE: add fix-it hint for . vs ->
- Authentication-results: sourceware.org; auth=none
- References: <1447173325-48683-1-git-send-email-dmalcolm at redhat dot com> <1447173325-48683-2-git-send-email-dmalcolm at redhat dot com>
On Tue, 10 Nov 2015, David Malcolm wrote:
> This is the most trivial example of a real fix-it example I could think
> of: if the user writes
> ptr.field
> rather than ptr->field.
>
> gcc/c/ChangeLog:
> * c-typeck.c (build_component_ref): Special-case POINTER_TYPE when
> generating a "not a structure of union" error message, and
> suggest a "->" rather than a ".", providing a fix-it hint.
I wonder if this should be restricted to the case where the pointer's
target is of structure or union type. At least, if it's some other type,
more of a fix is needed than just using -> (e.g. converting from void * to
a pointer to the relevant type).
--
Joseph S. Myers
joseph@codesourcery.com