Tested x86_64-pc-linux-gnu, applying to trunk.
-- 8< --
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.
---
gcc/cp/call.cc | 2 +-
gcc/testsuite/g++.dg/cpp2a/concepts-err5.C | 14 ++++++++++++++
2 files changed, 15 insertions(+), 1 deletion(-)
create mode 100644 gcc/testsuite/g++.dg/cpp2a/concepts-err5.C
diff --git a/gcc/cp/call.cc b/gcc/cp/call.cc
index 10c0cd9d065..00f6387e1cd 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 00000000000..d2fd179f4e4
--- /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" }
+}
base-commit: 49625b429b146235caf9066c54e106580935b9f8
--
2.56.0