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: 189633 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2bc4:b0:101:a8e8:374 with SMTP id hx4csp1169109dyb; Fri, 19 Jan 2024 09:49:03 -0800 (PST) X-Google-Smtp-Source: AGHT+IFdnPgq+2CEGEbQuYmZIcmfZu9l8Veh711fGDuvqKT8M6AvSpWxbspLReRY74zbtfjI6coT X-Received: by 2002:ac8:5c54:0:b0:429:f34b:8b4 with SMTP id j20-20020ac85c54000000b00429f34b08b4mr2076695qtj.27.1705686543098; Fri, 19 Jan 2024 09:49:03 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1705686543; cv=pass; d=google.com; s=arc-20160816; b=PHhLdC2qhfxc4/mALVkmXS5X+5YXOe5gNQ5hkRm6cLZqVCcDkrA3zV2gjhBSfF6DGw 5/rX2Xe4O4SYoKwcrY8nueAsU52w8ouWxI8Y10e7DyYYZv0HhVDXUmlN3B5LRsAWxiA5 GmXQo/YB12D2JiA/xEHY+3oqVKgHTT2WxzMhPe6orbu4G5w/ku+FyeFGe2QFEZBrjTQT uwQ5b9byyPidD0ZfoEoTOzMRnRckv+m/6EmYFKxRKx8Cwg/0w2AQPjSV4VNLdvnJ95Lg FY4hDqtYeHWWr/JSuGZF3ImGOhfusxXdA5CM7KQBSokwX5tW6b9WB/NO58e0TYAGbdSS r1pw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:message-id:date:subject:to:from:dkim-signature :arc-filter:dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=6B3wqdl69xSkBr/d3m8RgXvXPJKGAsYgHvaMhxG6Mts=; fh=zSP9Z/xOHj5SuUPPVSStTox2VGm+p0Uo644NtF/AZic=; b=NiCXMU1QZWfhP+BWZ9/K2Y/F66SpwC3yKHdXs5Shp6WYjccVECHYiPDX4c7oj8ye7f c67abfWmkqRVlGWVnO9JT+Kpl7WIiDm2l7os7Hf0nofSahmuum+74YTI8o30dCq1j6BS 1sK1ozLaP+DoiYPlfWzwkMGr3PQxCR7Ifu/GTwDYpwdsxONBbmmNUHLnmkJeeBW3OM2D xpt4FWzW2Kjg000J+bM0b6WWnR+2010XXZlYElihxLsZRDJr2g8y3s53zoMAEcwUYxf3 j3qGJK6PKV64nLyfqr1bwip+u6JbiLfyGvrTX2BQG6lCEWSyeLiNkIBelE5/qgWQOnCe VqZw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=QLN58Dbf; dkim=pass header.i=@wanadoo.fr header.s=t20230301 header.b=GaG0smmx; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id c10-20020ac87dca000000b0042a00bbccf8si8611241qte.265.2024.01.19.09.49.02 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Jan 2024 09:49:03 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=QLN58Dbf; dkim=pass header.i=@wanadoo.fr header.s=t20230301 header.b=GaG0smmx; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id BCAB23858C74 for ; Fri, 19 Jan 2024 17:49:02 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org BCAB23858C74 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1705686542; bh=6B3wqdl69xSkBr/d3m8RgXvXPJKGAsYgHvaMhxG6Mts=; h=From:To:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From; b=QLN58DbfrMUXhgtxZI0HqTfds/+hjQF4IHz/pMnre4AO6olkKYhOtvJpki9N/rmNO kmSISXOxbbCKxZWDnXdxQhwLz1ECnFdvMGAMML9MACyYxhAa290ploI6dI2B7OIFSL mObEkxpgO8Ztb/25tgN5MT8n/IfRfh0yeYcdbVE0= 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+ouuuleilei=gmail.com@gcc.gnu.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1788541972646919516 X-GMAIL-MSGID: 1788541972646919516 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;