From patchwork Fri Jan 19 17:47:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mikael Morin X-Patchwork-Id: 1888599 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=Eogiw7mA; dkim=pass (2048-bit key; unprotected) header.d=wanadoo.fr header.i=@wanadoo.fr header.a=rsa-sha256 header.s=t20230301 header.b=GaG0smmx; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4TGnCd1824z1yPV for ; Sat, 20 Jan 2024 04:48:28 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 0A60E3858C56 for ; Fri, 19 Jan 2024 17:48:26 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0A60E3858C56 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1705686506; bh=6B3wqdl69xSkBr/d3m8RgXvXPJKGAsYgHvaMhxG6Mts=; h=From:To:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From; b=Eogiw7mA4HRaIaw/nrf1nO5+4CupgP33I25rCHIF2jN9VlU/TlDN3q0bqY22oIjaj DhDxrfwp4XSyNxFyztI48oh2zy2SIoCe3rgtdoa691dtKT5SwexPWRaw2MsdtYyV3E 5KVxEpbW4faj/bo+/hc+ZEFRn40/6AsobUZRsesA= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from smtp.smtpout.orange.fr (smtp-27.smtpout.orange.fr [80.12.242.27]) by sourceware.org (Postfix) with ESMTPS id BF1723858C74; Fri, 19 Jan 2024 17:47:47 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org BF1723858C74 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=gcc.gnu.org Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=gcc.gnu.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org BF1723858C74 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=80.12.242.27 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1705686470; cv=none; b=giuLjgfXVMFDuvCm2Oz1+kaSckV6Dg6LXq4TlhemdRpsV/XtWImIW/WzsREDleRDmDiQsvdNasFsioOLwcA9fprCEe+HBUBAQcMtp32fOqwuaTo13pcdaVJrYCDI/Crw/YDZs2ZpUX5h/HOifOZ2Xnw/QNMtQJmUeFt6swdnVqw= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1705686470; c=relaxed/simple; bh=STLqdOI09AtuImnlCXZGkwd4OQrF8zfzDX05gqNgTQQ=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=Z5peXCL+oN241q2Nd6jjczCyadyWk2IzY+mSPnUPqT80ux4Iz6HfImPyS5IZ4ltXgdnCCkR+Ct3Ooyyf6hPE+bsNQE6pIYIs+NppO7/DO2E+6tFwFq0sr0yCfpXwJ/0lxwpRHHCqfmNXnYz/+UHX/JuIH1OC7HVb9wC/cQpYONo= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from cyrano.home ([86.215.161.51]) by smtp.orange.fr with ESMTPA id QsxsrseTZXxn1Qsy1rCux2; Fri, 19 Jan 2024 18:47:46 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wanadoo.fr; s=t20230301; t=1705686466; bh=6B3wqdl69xSkBr/d3m8RgXvXPJKGAsYgHvaMhxG6Mts=; h=From:To:Subject:Date; b=GaG0smmxW1QVFi8/vH3iSeF/1VJxUjY1KzOvRB6a+Vgtm4CoYO41kHr4MvheE+bFg Mfy/0ar4ETNd2jdL2Q99mnZAWJwC4H8sFWPIlhRB3dV6idZTCmmKf31laMVZhtULbu Rjw9KhHL2zkVoXQZ3F+l4e69hsEuvaciauwWgdcyze2KmjeWs7TbIbI9JFxihXW5Dc oAB4CmMg2iGGLS5tiCw112rOROSSfTAurYb++bVX4MMyYkN7x9GDWk+1CyL1SLnjea VQMz7nvEvsz7ODGJ8LeUYVbH8EjTS7QTIveDnZCNsiMQovFEauTrrYO+4RiGLR682U AdpmNNxdxB0fA== X-ME-Helo: cyrano.home X-ME-Auth: bW9yaW4tbWlrYWVsQG9yYW5nZS5mcg== X-ME-Date: Fri, 19 Jan 2024 18:47:46 +0100 X-ME-IP: 86.215.161.51 From: Mikael Morin To: fortran@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [PATCH] fortran: Restore current interface info on error [PR111291] Date: Fri, 19 Jan 2024 18:47:36 +0100 Message-ID: <20240119174736.1434406-1-mikael@gcc.gnu.org> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 X-Spam-Status: No, score=-11.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, FORGED_SPF_HELO, GIT_PATCH_0, JMQ_SPF_NEUTRAL, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H5, RCVD_IN_MSPIKE_WL, SPF_HELO_PASS, SPF_NEUTRAL, TXREP, T_SCC_BODY_TEXT_LINE 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+incoming=patchwork.ozlabs.org@gcc.gnu.org Hello, I tested this on x86_64-pc-linux-gnu without regression. There is no new test, as the problem is visible on an existing test with valgrind or an asan-instrumented compiler. OK for master? -- >8 -- This change is a followup to the fix for PR48776 (namely r14-3572-gd58150452976c4ca65ddc811fac78ef956fa96b0 AKA fortran: Restore interface to its previous state on error [PR48776]), which cleaned up new changes from interfaces upon error. Unfortunately, there is one case in that fix that is mishandled, visible on unexpected_interface.f90 with valgrind or an asan-instrumented gfortran. when an interface statement is found while parsing an interface body (which is invalid), the current interface is replaced by the one from the new statement, and as parsing continues, new procedures are added to the new interface, which has been rejected and freed, instead of the original one. This change restores the current interface pointer to its previous value on each rejected statement. PR fortran/48776 PR fortran/111291 gcc/fortran/ChangeLog: * parse.cc: Restore current interface to its previous value on error. --- gcc/fortran/parse.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/gcc/fortran/parse.cc b/gcc/fortran/parse.cc index abd3a424f38..51e89e10e2d 100644 --- a/gcc/fortran/parse.cc +++ b/gcc/fortran/parse.cc @@ -4033,6 +4033,7 @@ loop: default: gfc_error ("Unexpected %s statement in INTERFACE block at %C", gfc_ascii_statement (st)); + current_interface = save; reject_statement (); gfc_free_namespace (gfc_current_ns); goto loop;