public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/95073] New: Add "did you mean" when fn declaration could be found via ADL
@ 2020-05-12 4:13 mpolacek at gcc dot gnu.org
2020-05-12 7:58 ` [Bug c++/95073] " redi at gcc dot gnu.org
2020-05-12 8:30 ` redi at gcc dot gnu.org
0 siblings, 2 replies; 3+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2020-05-12 4:13 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95073
Bug ID: 95073
Summary: Add "did you mean" when fn declaration could be found
via ADL
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: mpolacek at gcc dot gnu.org
Target Milestone: ---
namespace N {
struct X { };
void f(X);
}
void
g ()
{
extern void f(); // #1
N::X x;
f(x); // calls locally declared function #1, no ADL
}
we issue
q.C: In function ‘void g()’:
q.C:11:6: error: too many arguments to function ‘void f()’
11 | f(x);
| ^
q.C:9:15: note: declared here
9 | extern void f();
| ^
but we could do better and say
q.C:11:3: error: too many arguments to function call, expected 0, have 1; did
you mean 'N::f'?
f(x);
^
N::f
q.C:3:8: note: 'N::f' declared here
void f(X);
^
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug c++/95073] Add "did you mean" when fn declaration could be found via ADL
2020-05-12 4:13 [Bug c++/95073] New: Add "did you mean" when fn declaration could be found via ADL mpolacek at gcc dot gnu.org
@ 2020-05-12 7:58 ` redi at gcc dot gnu.org
2020-05-12 8:30 ` redi at gcc dot gnu.org
1 sibling, 0 replies; 3+ messages in thread
From: redi at gcc dot gnu.org @ 2020-05-12 7:58 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95073
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Ever confirmed|0 |1
Last reconfirmed| |2020-05-12
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug c++/95073] Add "did you mean" when fn declaration could be found via ADL
2020-05-12 4:13 [Bug c++/95073] New: Add "did you mean" when fn declaration could be found via ADL mpolacek at gcc dot gnu.org
2020-05-12 7:58 ` [Bug c++/95073] " redi at gcc dot gnu.org
@ 2020-05-12 8:30 ` redi at gcc dot gnu.org
1 sibling, 0 replies; 3+ messages in thread
From: redi at gcc dot gnu.org @ 2020-05-12 8:30 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95073
--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
This part is still useful, to show the one that *was* found, but couldn't be
called:
q.C:9:15: note: declared here
9 | extern void f();
| ^
If that is replaced then it's not clear why "expected 0" would be true, and why
N::f wasn't found by ADL. It might also be helpful to explain that a block
scope function declaration suppresses ADL.
So maybe keep the current diagnostic unchanged, but then add a new note after
it?
q.C: In function ‘void g()’:
q.C:11:6: error: too many arguments to function ‘void f()’
11 | f(x);
| ^
q.C:9:15: note: declared here
9 | extern void f();
| ^
q.C:11:3: note: block-scope function declaration prevents argument dependent
lookup for unqualified name; did you mean 'N::f'?
f(x);
^
N::f
q.C:3:8: note: 'N::f' declared here
void f(X);
^
It might be better to say "local" instead of "block-scope" (not strictly
correct, but more likely to be understood by users).
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-05-12 8:30 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-12 4:13 [Bug c++/95073] New: Add "did you mean" when fn declaration could be found via ADL mpolacek at gcc dot gnu.org
2020-05-12 7:58 ` [Bug c++/95073] " redi at gcc dot gnu.org
2020-05-12 8:30 ` redi at gcc dot gnu.org
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).