From patchwork Wed Sep 17 20:47:40 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Malcolm X-Patchwork-Id: 120443 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 95FD93858C41 for ; Wed, 17 Sep 2025 20:54:47 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 95FD93858C41 Authentication-Results: sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=etEj+QOm X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTP id 6D48B3858C2C for ; Wed, 17 Sep 2025 20:47:51 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 6D48B3858C2C Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 6D48B3858C2C Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1758142071; cv=none; b=NA3KEjRqXE3uE+Ct50+JwOgHUsrzTHsXHuIV6zwYZ4oAE5wFIBt04vNwNSPs8Y6Tgg/jFLein7bKd4AXyDRB1Zi12vkSYRaRbXd788TFEMrOGv9vu4JcFgLJvyLJtiilPCvAou2kqJRE76HV7pLQI1zfRbaQsLrg7b+cOOXEs9E= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1758142071; c=relaxed/simple; bh=zj1EN8+RU9t3YKSl9dakxsJb5g9Wkm7Zdt6X+97HCN0=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=jTJAYopQYydaVq2MqgN6q2UJyemJvAAoQr233HGMWFEbOaGwS3fuLcqHfIiBjdkqU2u/rf+o1uW5J1hIqLgA9nS+IRmk/shY8SLPvlA9WxQdZ+FpbHJa7Tb5leYsmgwrP5QdnxxKCzR8vy5XewrfcSi458Q7FP1PPUhChq8/s2I= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6D48B3858C2C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1758142071; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=+UQHJDNpK3ZvpS5T/8qwAxNAqa+zHGnpb+UNHwB0JDI=; b=etEj+QOmimYS9ILrLDv/klvY8fOw+9oUC5M4T3g+XOb+njRYMIpgb6XkN2560xuo43VFu7 M/WH3KfxoUdIa94t+SY0nW5zT2vsdTrbhlNOdjMy+HENALPkeA+LgQlp5Yo2DQn0RYKboq PYX6lI7lEx0g+Gz/UGtSfIDceo0TmKY= Received: from mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-154-zqyq4sYDN4OPqO_lbt0Sdg-1; Wed, 17 Sep 2025 16:47:43 -0400 X-MC-Unique: zqyq4sYDN4OPqO_lbt0Sdg-1 X-Mimecast-MFC-AGG-ID: zqyq4sYDN4OPqO_lbt0Sdg_1758142063 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id E0362195608A for ; Wed, 17 Sep 2025 20:47:42 +0000 (UTC) Received: from t14s.localdomain (unknown [10.22.81.11]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 440A1300018D; Wed, 17 Sep 2025 20:47:41 +0000 (UTC) From: David Malcolm To: gcc-patches@gcc.gnu.org Cc: David Malcolm Subject: [pushed: r16-3941] c++: improve nesting in print_z_candidate [PR121966] Date: Wed, 17 Sep 2025 16:47:40 -0400 Message-ID: <20250917204740.2386457-1-dmalcolm@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: EVogSNvuK3lVm2CMkXSuJUCy-yArmjiU8MMXpUWFxTY_1758142063 X-Mimecast-Originator: redhat.com content-type: text/plain; charset="US-ASCII"; x-default=true X-Spam-Status: No, score=-11.6 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H5, RCVD_IN_MSPIKE_WL, RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED, SPF_HELO_PASS, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces~patchwork=sourceware.org@gcc.gnu.org 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 "