Comment #2 of PR c++/121966 notes that the "inherited here" messages
should be nested *within* the note they describe.
Implemented by this patch, which also nests other notes emitted for
rejection_reason within the first note of print_z_candidate.
Successfully bootstrapped & regrtested on x86_64-pc-linux-gnu.
Pushed to trunk as r16-3941-g41f071a64ff702.
gcc/cp/ChangeLog:
PR c++/121966
* call.cc (print_z_candidate): Consolidate instances of
auto_diagnostic_nesting_level into one, above the "inherited here"
message so that any such message is nested within the note,
and any messages emitted due to the switch on rejection_reason are
similarly nested within the note.
---
gcc/cp/call.cc | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/gcc/cp/call.cc b/gcc/cp/call.cc
index d11961a48ada..550ce5f712be 100644
--- a/gcc/cp/call.cc
+++ b/gcc/cp/call.cc
@@ -4104,15 +4104,18 @@ print_z_candidate (location_t loc, const char *msgstr,
inform (cloc, "%s%#qD (rewritten)", msg, fn);
else
inform (cloc, "%s%#qD", msg, fn);
+
+ auto_diagnostic_nesting_level sentinel;
+
if (fn != candidate->fn)
{
cloc = location_of (candidate->fn);
inform (cloc, "inherited here");
}
+
/* Give the user some information about why this candidate failed. */
if (candidate->reason != NULL)
{
- auto_diagnostic_nesting_level sentinel;
struct rejection_reason *r = candidate->reason;
switch (r->code)
@@ -4172,10 +4175,7 @@ print_z_candidate (location_t loc, const char *msgstr,
"class type is invalid");
break;
case rr_constraint_failure:
- {
- auto_diagnostic_nesting_level sentinel;
- diagnose_constraints (cloc, fn, NULL_TREE);
- }
+ diagnose_constraints (cloc, fn, NULL_TREE);
break;
case rr_inherited_ctor:
inform (cloc, "an inherited constructor is not a candidate for "
--
2.26.3