[cfe-commits] [PATCH] Member reference fixit (bug 6800)

Douglas Gregor dgregor at apple.com
Tue Jan 24 09:54:58 PST 2012

On Jan 21, 2012, at 11:42 PM, Aaron Ballman wrote:

> I've attached a patch to fix bug 6800 (and test cases) so that a
> proper fixit is output when dereferencing using -> instead of .  We
> were missing the fixit when looking up overloaded operator -> and
> emitting a diagnostic.

This goes in the right direction, but there's a bit more we need. We only emit a Fix-It when the compiler can recover as if you had typed when we're suggesting. In this case, we'll still end up returning an error expression, which suppresses a lot of important type checking. In this particular case, we'd need to communicate up to the caller that the user meant to type a "." but typed an "->" instead.

Moreover, you should customize the error message in this case. Perhaps something like "type %0 is not a pointer and does not have an overloaded 'operator->'; did you mean to use '.'?".

	- Doug

More information about the cfe-commits mailing list