[PATCH] v4: C/C++: add fix-it hints for missing '&' and '*' (PR c++/87850)

David Malcolm dmalcolm@redhat.com
Wed Dec 5 16:18:00 GMT 2018


On Wed, 2018-12-05 at 11:03 -0500, Jason Merrill wrote:
> On Mon, Dec 3, 2018 at 5:14 PM Joseph Myers <joseph@codesourcery.com>
> wrote:
> > 
> > On Sat, 1 Dec 2018, Jason Merrill wrote:
> > 
> > > Hmm, it looks like the C front-end comptypes will return 1 for
> > > e.g. enum and
> > > int.  It seems to me that what you want for this warning is
> > > actually to check
> > > for the same type.  Perhaps you want to use
> > > comptypes_check_different_types?
> > > Joseph would know better what's correct for the C front-end.
> > 
> > Well, it's valid to pass a pointer to enum where a pointer to the
> > compatible integer type is required, or vice versa, but I don't
> > have
> > advice on which cases you want to accept for this particular fix-
> > it.
> 
> Since the diagnostic is about returning, e.g. an int when an int* is
> needed, or vice versa, I don't think considering that kind of
> conversion is helpful.

FWIW I'd be happy to use simple pointer equality of the types for the C
FE, so that we only emit the suggestion for an exact match (better to
fail to offer a suggestion than to offer a bogus one, I think).

Dave



More information about the Gcc-patches mailing list