[Bug c++/95073] Add "did you mean" when fn declaration could be found via ADL

redi at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Tue May 12 08:30:39 GMT 2020


--- 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

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

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

More information about the Gcc-bugs mailing list