diff options
author | Patrick Palka <ppalka@redhat.com> | 2020-03-28 08:56:33 -0400 |
---|---|---|
committer | Patrick Palka <ppalka@redhat.com> | 2020-03-28 08:56:33 -0400 |
commit | cd68edf894d6b72e5bc37ac205deef9d237ab70b (patch) | |
tree | 1ba70ce7194fddbe4c30a12da104d061ffe4c661 /gcc/cp/constraint.cc | |
parent | 75defde9fb56157d5f0279720d48866925b71b19 (diff) | |
download | gcc-cd68edf894d6b72e5bc37ac205deef9d237ab70b.zip gcc-cd68edf894d6b72e5bc37ac205deef9d237ab70b.tar.gz gcc-cd68edf894d6b72e5bc37ac205deef9d237ab70b.tar.bz2 |
c++: Respect current_constraint_diagnosis_depth in diagnose_compound_requirement
The previous patch tries to avoid changing our current default diagnostics. But
for the sake of consistency we arguably should also respect
current_constraint_diagnosis_depth in diagnose_compound_requirement() like we do
in the other error-replaying diagnostic routines. But doing so would be a
change to our default diagnostics behavior, so the change has been split out
into this separate patch for separate consideration.
gcc/cp/ChangeLog:
* constraint.cc (diagnose_compound_requirement): When diagnosing a
compound requirement, maybe replay the satisfaction failure, subject to
the current diagnosis depth.
gcc/testsuite/ChangeLog:
* g++.dg/concepts/diagnostic1.C: Pass -fconcepts-diagnostics-depth=2.
* g++.dg/concepts/diagnostic5.C: Adjust expected diagnostics.
* g++.dg/cpp2a/concepts-iconv1.C: Pass -fconcepts-diagnostics-depth=2.
* g++.dg/cpp2a/concepts-requires5.C: Likewise.
Diffstat (limited to 'gcc/cp/constraint.cc')
-rw-r--r-- | gcc/cp/constraint.cc | 28 |
1 files changed, 19 insertions, 9 deletions
diff --git a/gcc/cp/constraint.cc b/gcc/cp/constraint.cc index 76c5203..571c7cb 100644 --- a/gcc/cp/constraint.cc +++ b/gcc/cp/constraint.cc @@ -3308,20 +3308,30 @@ diagnose_compound_requirement (tree req, tree args, tree in_decl) if (!type_deducible_p (expr, type, placeholder, args, quiet)) { tree orig_expr = TREE_OPERAND (req, 0); - inform (loc, "%qE does not satisfy return-type-requirement", - orig_expr); - - /* Further explain the reason for the error. */ - type_deducible_p (expr, type, placeholder, args, noisy); + if (diagnosing_failed_constraint::replay_errors_p ()) + { + inform (loc, + "%qE does not satisfy return-type-requirement, " + "because", orig_expr); + /* Further explain the reason for the error. */ + type_deducible_p (expr, type, placeholder, args, noisy); + } + else + inform (loc, "%qE does not satisfy return-type-requirement", + orig_expr); } } else if (!expression_convertible_p (expr, type, quiet)) { tree orig_expr = TREE_OPERAND (req, 0); - inform (loc, "cannot convert %qE to %qT", orig_expr, type); - - /* Further explain the reason for the error. */ - expression_convertible_p (expr, type, noisy); + if (diagnosing_failed_constraint::replay_errors_p ()) + { + inform (loc, "cannot convert %qE to %qT because", orig_expr, type); + /* Further explain the reason for the error. */ + expression_convertible_p (expr, type, noisy); + } + else + inform (loc, "cannot convert %qE to %qT", orig_expr, type); } } } |