https://gcc.gnu.org/g:f2977b445ea1bb99556061ce687eda21960b4f59
commit r17-6176-gf2977b445ea1bb99556061ce687eda21960b4f59 Author: Jason Merrill <[email protected]> Date: Tue Nov 10 12:42:30 2026 -0500 c++: fix -fdiagnostics-all-candidates with concepts I noticed that in a case where one candidate has a bad conversion and all others have unsatisfied constraints, the diagnostic only talked about the bad conversion candidate, and -fdiagnostics-all-candidates didn't help. gcc/cp/ChangeLog: * call.cc (splice_viable): Strict if -fdiagnostics-all-candidates. gcc/testsuite/ChangeLog: * g++.dg/cpp2a/concepts-err5.C: New test. Diff: --- gcc/cp/call.cc | 2 +- gcc/testsuite/g++.dg/cpp2a/concepts-err5.C | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/gcc/cp/call.cc b/gcc/cp/call.cc index 10c0cd9d0656..00f6387e1cdb 100644 --- a/gcc/cp/call.cc +++ b/gcc/cp/call.cc @@ -3928,7 +3928,7 @@ splice_viable (struct z_candidate *cands, /* Be strict inside templates, since build_over_call won't actually do the conversions to get pedwarns. */ - if (processing_template_decl) + if (processing_template_decl || flag_diagnostics_all_candidates) strict_p = true; for (z_candidate *cand = cands; cand; cand = cand->next) diff --git a/gcc/testsuite/g++.dg/cpp2a/concepts-err5.C b/gcc/testsuite/g++.dg/cpp2a/concepts-err5.C new file mode 100644 index 000000000000..d2fd179f4e49 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp2a/concepts-err5.C @@ -0,0 +1,14 @@ +// { dg-do compile { target c++20 } } +// { dg-additional-options -fdiagnostics-all-candidates } + +template <class T> +struct A { + void f(); // { dg-message "discards qualifiers" } + void f() const requires (__is_same (T, int)); // { dg-message "'char' is not the same as 'int'" } +}; + +int main() +{ + const A<char> a; + a.f(); // { dg-error "no match" } +}
