From patchwork Sun Dec 7 23:36:09 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Egas Ribeiro X-Patchwork-Id: 126105 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 899BB43413FE for ; Sun, 7 Dec 2025 23:37:47 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 899BB43413FE Authentication-Results: sourceware.org; dkim=pass (2048-bit key, secure) header.d=tecnico.ulisboa.pt header.i=@tecnico.ulisboa.pt header.a=rsa-sha256 header.s=mail2 header.b=jtxfvUBt X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from smtp1.tecnico.ulisboa.pt (smtp1.tecnico.ulisboa.pt [193.136.128.21]) by sourceware.org (Postfix) with ESMTPS id 9F25D43413E2 for ; Sun, 7 Dec 2025 23:37:02 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 9F25D43413E2 Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=tecnico.ulisboa.pt Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=tecnico.ulisboa.pt ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 9F25D43413E2 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=193.136.128.21 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1765150622; cv=none; b=dWs6cN4wv+XVcDRs6jl3/jqEju3MfIg2DJZ8fnDwhfwA8fGwQvdRgUyjAkuYMUmfbxy2fwi23QqPnNtKMWKBMm5qfKtJcnPegHV6PkgQfqN5O3AID3rqCx95Fw5BA/PvOXXrnDL65pVCoiVfqGadnmKK8MhzyazkF1scKYrPACM= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1765150622; c=relaxed/simple; bh=1566C/lYzNRUdlZs3UBv+sfuVctt0VZiLens11XVRto=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=sV9uEyeymEB+bNgMej+waXvecb/eoQqFm4y6eGSiuJw3Q7jT67cHS7HIZvItDgccHIZBta4eyMGCeKZ5IlQYIeRpMScOJsYz86Wy9XrGCblUFL+1+Wt3k30CO2Jtv8Sbo08YqqudE+L7L9AYuVx9bUXSDZTjRcmsx5YcNkRMkDc= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9F25D43413E2 Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp1.tecnico.ulisboa.pt (Postfix) with ESMTP id A55226002984; Sun, 7 Dec 2025 23:37:01 +0000 (WET) X-Virus-Scanned: by amavis-2.13.0 (20230106) (Debian) at tecnico.ulisboa.pt Received: from smtp1.tecnico.ulisboa.pt ([127.0.0.1]) by localhost (smtp1.tecnico.ulisboa.pt [127.0.0.1]) (amavis, port 10025) with LMTP id ip9v9Lxx__2s; Sun, 7 Dec 2025 23:36:59 +0000 (WET) Received: from mail1.tecnico.ulisboa.pt (mail1.ist.utl.pt [193.136.128.10]) by smtp1.tecnico.ulisboa.pt (Postfix) with ESMTPS id 12CED600022C; Sun, 7 Dec 2025 23:36:59 +0000 (WET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tecnico.ulisboa.pt; s=mail2; t=1765150619; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=ghde1hxsJq3+Bbsby2b9rQlVMpJiJRYt8oFkpK0QtoY=; b=jtxfvUBtZ9ow2RETsd+vVA7yTPNS3FKNsfOGOqCS/mnOzPsuupCk0j/OGPs+HgqrP58bmK +m/zwVF7BW5UiUyZDIHxVBSecLq0kJA98mWVNzC/nS25UieF+uPWu5veM1+fguVLh8cwrK bkRomDel3VgDDhaJYmdORfj4iFOsGBYDPBojLtbRaOrrwXTVI6Ew9YSLjqtcxpuXjdw+Nn VwK94Zy20fRGTv0uOMupl2kjcuuIJJaV8f3/O+wMGdTpNtkYCXMjqtwB6yYxjYxpgg1aWn C2IAzu4hsfM1l+qHhkZWpGa7RZpQKEK0GWvocn1uVN1iKF1yp+ORrYw0SIl2rA== Received: from archlinux (bl23-255-114.dsl.telepac.pt [144.64.255.114]) (Authenticated sender: ist1110454) by mail1.tecnico.ulisboa.pt (Postfix) with ESMTPSA id DFB643600CB; Sun, 7 Dec 2025 23:36:58 +0000 (WET) From: Egas Ribeiro To: gcc-patches@gcc.gnu.org Cc: jason@redhat.com, ppalka@redhat.com, Egas Ribeiro Subject: [PATCH] c++: Handle error_mark_node in mark_used and mark_single_function Date: Sun, 7 Dec 2025 23:36:09 +0000 Message-ID: <20251207233608.1078876-2-egas.g.ribeiro@tecnico.ulisboa.pt> X-Mailer: git-send-email 2.52.0 MIME-Version: 1.0 X-Spam-Status: No, score=-12.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, GIT_PATCH_0, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on 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 These functions should return false for error_mark_node to properly propagate errors from callers. gcc/cp/ChangeLog: * decl2.cc (mark_single_function): Return false for error_mark_node. (mark_used): Likewise. gcc/testsuite/ChangeLog: * g++.dg/DRs/dr3061.C: Remove cascading error expectation. * g++.dg/cpp0x/initlist31.C: Likewise. Signed-off-by: Egas Ribeiro --- gcc/cp/decl2.cc | 7 ++++++- gcc/testsuite/g++.dg/DRs/dr3061.C | 2 +- gcc/testsuite/g++.dg/cpp0x/initlist31.C | 2 +- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/gcc/cp/decl2.cc b/gcc/cp/decl2.cc index 8ec9740c8a9..5c254506153 100644 --- a/gcc/cp/decl2.cc +++ b/gcc/cp/decl2.cc @@ -6301,6 +6301,9 @@ mark_single_function (tree expr, tsubst_flags_t complain) expr = maybe_undo_parenthesized_ref (expr); expr = tree_strip_any_location_wrapper (expr); + if (expr == error_mark_node) + return false; + if (is_overloaded_fn (expr) == 1 && !mark_used (expr, complain) && !(complain & tf_error)) @@ -6343,10 +6346,12 @@ fn_template_being_defined (tree decl) bool mark_used (tree decl, tsubst_flags_t complain /* = tf_warning_or_error */) { + if (decl == error_mark_node) + return false; /* If we're just testing conversions or resolving overloads, we don't want any permanent effects like forcing functions to be output or instantiating templates. */ - if ((complain & tf_conv)) + if (complain & tf_conv) return true; /* If DECL is a BASELINK for a single function, then treat it just diff --git a/gcc/testsuite/g++.dg/DRs/dr3061.C b/gcc/testsuite/g++.dg/DRs/dr3061.C index 728829848f5..bd8b74cdafb 100644 --- a/gcc/testsuite/g++.dg/DRs/dr3061.C +++ b/gcc/testsuite/g++.dg/DRs/dr3061.C @@ -12,7 +12,7 @@ foo () template for (int x : { 1, }) // { dg-warning "'template for' only available with" "" { target c++23_down } } ; for (int x : { , }) // { dg-error "expected primary-expression before ',' token" } - ; // { dg-error "unable to deduce" "" { target *-*-* } .-1 } + ; template for (int x : { , }) // { dg-warning "'template for' only available with" "" { target c++23_down } } ; // { dg-error "expected primary-expression before ',' token" "" { target *-*-* } .-1 } } diff --git a/gcc/testsuite/g++.dg/cpp0x/initlist31.C b/gcc/testsuite/g++.dg/cpp0x/initlist31.C index a8a29f9c853..6d88edb397f 100644 --- a/gcc/testsuite/g++.dg/cpp0x/initlist31.C +++ b/gcc/testsuite/g++.dg/cpp0x/initlist31.C @@ -9,5 +9,5 @@ void f() { auto y = { string(Equation()) // { dg-error "12:'Equation' was not declared" } - }; // { dg-error "unable to deduce" } + }; }