http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24985
--- Comment #34 from Richard Guenther <rguenth at gcc dot gnu.org> 2012-04-13
09:56:48 UTC ---
(In reply to comment #32)
> (In reply to comment #31)
> > The effect of this patch on overload resolution diagnostics is problematic:
> > wa2.C: In function ‘int main()’:
> > wa2.C:6:6: error: no matching function for call to ‘f(int)’
> > f(1);
> > ^
> > wa2.C:6:6: note: candidates are:
> > f(1);
> > ^
> > wa2.C:1:6: note: void f()
> > void f();
> > ^
> > wa2.C:1:6: note: candidate expects 0 arguments, 1 provided
> > void f();
> > ^
> > wa2.C:2:6: note: void f(int, int)
> > void f(int,int);
> > ^
> > wa2.C:2:6: note: candidate expects 2 arguments, 1 provided
> > void f(int,int);
> > ^
> >
> > When there are multiple diagnostics at the same input location, we should
> > only
> > print the source/caret information once.
>
> True. Actually, in this case, perhaps we should print:
>
> wa2.C:6:6: error: no matching function for call to ‘f(int)’
> f(1);
> ^
> note: candidates are:
> wa2.C:1:6: note: candidate expects 0 arguments, 1 provided
> void f();
> ^
> wa2.C:2:6: note: candidate expects 2 arguments, 1 provided
> void f(int,int);
> ^
>
> no? Any other suggestions?
>
> We could also print the %qD in the same line as:
>
> wa2.C:6:6: error: no matching function for call to ‘f(int)’
> f(1);
> ^
> note: candidates are:
> wa2.C:1:6: note: candidate 'void f()' expects 0 arguments, 1 provided
> void f();
> ^
> wa2.C:2:6: note: candidate 'void f(int, int)' expects 2 arguments, 1
> provided
> void f(int,int);
> ^
>
> What do you think?
I think we should simply omit carets for all 'note's for now and add a
way for the callers to suppress carets. Though if you consider the testcase
changed to
void f(); void f(int,int);
int main()
{
f(1);
}
then suddenly the carets get more useful and the situation less clear:
t.C: In function 'int main()':
t.C:5:6: error: no matching function for call to 'f(int)'
f(1);
^
t.C:5:6: note: candidates are:
f(1);
^
t.C:1:6: note: void f()
void f(); void f(int,int);
^
t.C:1:6: note: candidate expects 0 arguments, 1 provided
void f(); void f(int,int);
^
t.C:1:17: note: void f(int, int)
void f(); void f(int,int);
^
t.C:1:17: note: candidate expects 2 arguments, 1 provided
void f(); void f(int,int);
^
btw, why do we print a location info for
t.C:5:6: note: candidates are:
f(1);
^
at all?
t.C:1:6: note: candidate expects 0 arguments, 1 provided
void f(); void f(int,int);
^
t.C:1:17: note: void f(int, int)
void f(); void f(int,int);
^
and the 2nd note here looks wrong.