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 missing '&' and '*' (PR c++/87850)
On Sun, 2018-11-11 at 11:01 -0700, Martin Sebor wrote:
> On 11/10/2018 12:01 AM, Eric Gallager wrote:
> > On 11/9/18, David Malcolm <dmalcolm@redhat.com> wrote:
> > > This patch adds a fix-it hint to various pointer-vs-non-pointer
> > > diagnostics, suggesting the addition of a leading '&' or '*'.
> > >
> > > For example, note the ampersand fix-it hint in the following:
> > >
> > > demo.c:5:22: error: invalid conversion from 'pthread_key_t' {aka
> > > 'unsigned
> > > int'}
> > > to 'pthread_key_t*' {aka 'unsigned int*'} [-fpermissive]
> > > 5 | pthread_key_create(key, NULL);
> > > | ^~~
> > > | |
> > > | pthread_key_t {aka unsigned int}
> > > | &
> >
> > Having both the type and the fixit underneath the caret looks kind
> > of confusing
>
> I agree it's rather subtle. Keeping the diagnostics separate from
> the suggested fix should avoid the confusion.
FWIW, the fix-it hint is in a different color (assuming that gcc is
invoked in an environment that prints that...)
Dave