[PATCH 02/02] C FE: add fix-it hint for . vs ->
Joseph Myers
joseph@codesourcery.com
Tue Nov 10 17:55:00 GMT 2015
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
More information about the Gcc-patches
mailing list