On 10/27/23 15:55, Patrick Palka wrote:
With the previous two patches in place, we can now extend our
deletedness diagnostic to note the other considered candidates, e.g.:

   deleted16.C: In function 'int main()':
   deleted16.C:10:4: error: use of deleted function 'void f(int)'
      10 |   f(0);
         |   ~^~~
   deleted16.C:5:6: note: declared here
       5 | void f(int) = delete;
         |      ^
   deleted16.C:5:6: note: candidate: 'void f(int)' (deleted)
   deleted16.C:6:6: note: candidate: 'void f(...)'
       6 | void f(...);
         |      ^
   deleted16.C:7:6: note: candidate: 'void f(int, int)'
       7 | void f(int, int);
         |      ^
   deleted16.C:7:6: note:   candidate expects 2 arguments, 1 provided

These notes are controlled by a new command line flag -fnote-all-cands,
which also controls whether we note ignored candidates more generally.

gcc/ChangeLog:

        * doc/invoke.texi (C++ Dialect Options): Document -fnote-all-cands.

gcc/c-family/ChangeLog:

        * c.opt: Add -fnote-all-cands.

gcc/cp/ChangeLog:

        * call.cc (print_z_candidates): Only print ignored candidates
        when -fnote-all-cands is set.
        (build_over_call): When diagnosing deletedness, call
        print_z_candidates if -fnote-all-cands is set.

My suggestion was also to suggest using the flag in cases where it would make a difference, e.g.

note: some candidates omitted, use '-fnote-all-cands' to display them

Maybe "-fdiagnostics-all-candidates"?

Jason

Reply via email to