On Tue, Jan 24, 2012 at 6:54 PM, Douglas Gregor <[email protected]> wrote:
>
> 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.

I've been trying various ways to implement this, but what I'm finding
is that by attempting to recover, the error gets re-generated
elsewhere (SemaMemberExpr.cpp's LookupMemberExpr to be exact).  So we
end up emitting the diagnostic twice in that scenario.

> 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 '.'?".

Good call!

I've attached a second attempt, but because I am leaving out the
diagnostic for operator-> (so as not to get duplicate diagnostics), I
don't think I've quite got it right.  If you have suggestions, I'd
love to hear them.

Thanks!

~Aaron

Attachment: member_ref_fixit 2.patch
Description: Binary data

_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to