From patchwork Thu Aug 29 19:31:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Harald Anlauf X-Patchwork-Id: 1978599 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=gmx.de header.i=anlauf@gmx.de header.a=rsa-sha256 header.s=s31663417 header.b=svEcEkPm; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; 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 [8.43.85.97]) (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 4WvryD5Jhzz1yfn for ; Fri, 30 Aug 2024 05:32:04 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 93E69385EC1B for ; Thu, 29 Aug 2024 19:32:02 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mout.gmx.net (mout.gmx.net [212.227.15.19]) by sourceware.org (Postfix) with ESMTPS id C4D19385EC1B; Thu, 29 Aug 2024 19:31:38 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C4D19385EC1B Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=gmx.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmx.de ARC-Filter: OpenARC Filter v1.0.0 sourceware.org C4D19385EC1B Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=212.227.15.19 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1724959900; cv=none; b=EYgtMEAp2S13ojO5B6aSGPyA8iw6M1ucuXtoZDfJXMb2FLM+Fe4qrlE/70o+TLpVbKQf2QvpGQzZOTlXph/a1rhCnXlAxpAyuJVBKWHhZKMF3yZ+b+Wt1EdYUwD1UlO5wQG6Q4E6f9dsEDRhspMcIr7UX9MWAyqQDWEoQxE0XME= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1724959900; c=relaxed/simple; bh=aNh5Aq94kfsYmMiLFz+CxiT+uV9++/kdNe8KGhOUD1k=; h=DKIM-Signature:MIME-Version:Message-ID:From:To:Subject:Date; b=nPBNbgsFu18UW8expIgr3kDETbOQynsNa/vEYZzSLZg/Mh1680pSSDOvScJuTRFZEWDXNmJ3gech7yAwA2ZU97ONcwglrjLxXT+rDUVRyUa+VDpa25ZpNFjTbcsqCHZCARhWPMwKYBte9oqmFwIdgoeKvib11cVvNlU4aMIU3o8= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmx.de; s=s31663417; t=1724959897; x=1725564697; i=anlauf@gmx.de; bh=SmUF+FNl2yGXrKkvUK06hYmwiX+UIm1jK0KS5rAtgbY=; h=X-UI-Sender-Class:MIME-Version:Message-ID:From:To:Subject: Content-Type:Date:cc:content-transfer-encoding:content-type:date: from:message-id:mime-version:reply-to:subject:to; b=svEcEkPmffWhtoyGwN2WAUj8mSbTdBYY9pRKd3IIwZOnJ7aY7EcZsogAamesqS6H y8sl1BjlEkioE3HxsKT9FaNTiPqtWaSCFg6SyHqCfV0AkeUybPr1XqtaoIbt4Axvy W/Qk+dx3KsIgMD9i6XG9CuFde2u5RFdED6FDaRYToc9NZcsUGm2iWQVP57BbQvS0G NXS37cNVyC90joMgJj2r75nrhHAfb5UVmht1EeKMCrWfUrIteYmGz45j2LhDX5W3s Uv3d02m90mcKCG+K35VicsNW/wABcG6EmxwOKPrmjhqh8QnloekdAt6SOUbyGvPGZ emJRkNqvIZwGjhnMsw== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from [79.232.158.172] ([79.232.158.172]) by web-mail.gmx.net (3c-app-gmx-bs45.server.lan [172.19.170.97]) (via HTTP); Thu, 29 Aug 2024 21:31:37 +0200 MIME-Version: 1.0 Message-ID: From: Harald Anlauf To: fortran , gcc-patches Subject: [PATCH, pushed] Fortran: fix ICE with use with rename of namelist member [PR116530] Date: Thu, 29 Aug 2024 21:31:37 +0200 Importance: normal Sensitivity: Normal X-Priority: 3 X-Provags-ID: V03:K1:JAOTu1yTsh+AxyrLy7H0nON4zB6am1qH8fG1zdRS/l8Zz9LuoB0jGgX8z1JqwWUiFNzVD GwKgSlVX06DQiRWMBwy9vDNLSwAEL8PBmK007CrT9R2GjC+2/gfLf954PeG0NmMVx7PNQzeyUm0r s5tqriOt74Jauh7Yh0p9yvsRumYBp/Ly6cMhidJbaqkgsSZEAOGlEqZB0jKzGmxvGo7nLdHLyAjA vleit+9Ua0bqHmDfOYgE9Y+0GJfMDDYgxBZMM+QShidtzSeBPeIkgUZFBAfEvcMLT1nkUY5Z4GvN YQ= UI-OutboundReport: notjunk:1;M01:P0:TXjxUF5w8jo=;8HJxeX48KjxkadKJQa6KLtL9USE UG4WFUUEYNqF4+l1wVgQjBPs1wd/zhJjaDMYVJscbVCVsuyWny8PNuZ11Fm6KeoPdqTl2ZV7Z kzmbKONSXv17/QNWNMoUVwRoCqwnrds6ZKPYjpoRkx9XG2zrU+YHjY+dt6FECOn7rySqSPNb6 7JRL3CPwlDgQMbgwv7CgkrHFJakip0iN9NaRgj+IAohMv0m4qkPOvds/NS/uS9iwmkyL4f5h0 t+FvJGfQrutXiBt/ZhUa5Zp6L+pflogCWZbNdk8vWhFWbEdu0G2WBlPrIuueceCJLzeDv18hh SP67qWhTnVxtie9UfhA7tvfGuP6IOA64SVEIe8gTrY2yLDQUP4J/oEjgED1Wq1EDvXiwBjoZ4 u3CImePn3Fu+xOKBnsajzJlbWjMTkcwo0bItRK4EdUaWWxYqTZaNvo0QXpcs2/tZdvDJTZHQT BhYd4ujd53dkLWCYzTwLvBartLBXGXQk9HD2W4TAMj6/7Iz+Zvm+3F/55yvEziPGZB4qipQ7V 8EHy63WkwLbROwD/7ZU8p5xvDkh9u9Y0r+XEmlQRV0PmWx2HMURT/3+B3I4+KcN9aXKW5lJgh EGQpnoVPQXQ97TQHMhAJUqpUKHP5WFSCMwDIbi0z0N9wupBS/0opIV7rUvLgA4geyraZxlic/ PUM5CY97KoWcj/6CfS//hqQc99GLTFRvs0aUwwB2Bg== X-Spam-Status: No, score=-12.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, 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 Dear all, the attached simple & obvious patch fixes a NULL pointer dereference when USEing with rename a namelist member and reading/writing the namelist. Patch was OK'ed in the PR by Steve and is pushed to mainline as: r15-3308-g6bfeba12c86b4d0dae27d99b484f64774dd49398 As this is a 14/15 regression, I plan to backport when it has successfully passed the testers. Thanks, Harald From 6bfeba12c86b4d0dae27d99b484f64774dd49398 Mon Sep 17 00:00:00 2001 From: Harald Anlauf Date: Thu, 29 Aug 2024 21:21:39 +0200 Subject: [PATCH] Fortran: fix ICE with use with rename of namelist member [PR116530] gcc/fortran/ChangeLog: PR fortran/116530 * trans-io.cc (transfer_namelist_element): Prevent NULL pointer dereference. gcc/testsuite/ChangeLog: PR fortran/116530 * gfortran.dg/use_rename_12.f90: New test. --- gcc/fortran/trans-io.cc | 3 ++- gcc/testsuite/gfortran.dg/use_rename_12.f90 | 27 +++++++++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gfortran.dg/use_rename_12.f90 diff --git a/gcc/fortran/trans-io.cc b/gcc/fortran/trans-io.cc index 7ab82fa2f5b..c0baa718ef6 100644 --- a/gcc/fortran/trans-io.cc +++ b/gcc/fortran/trans-io.cc @@ -1692,7 +1692,8 @@ transfer_namelist_element (stmtblock_t * block, const char * var_name, gcc_assert (sym || c); /* Build the namelist object name. */ - if (sym && !sym->attr.use_only && sym->attr.use_rename) + if (sym && !sym->attr.use_only && sym->attr.use_rename + && sym->ns->use_stmts->rename) string = gfc_build_cstring_const (sym->ns->use_stmts->rename->local_name); else string = gfc_build_cstring_const (var_name); diff --git a/gcc/testsuite/gfortran.dg/use_rename_12.f90 b/gcc/testsuite/gfortran.dg/use_rename_12.f90 new file mode 100644 index 00000000000..0447d5fe150 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/use_rename_12.f90 @@ -0,0 +1,27 @@ +! { dg-do compile } +! PR fortran/116530 - ICE with member of namelist renamed by use module +! +! Reported by philippe.wautelet at cnrs.fr + +module mod_nml1 + implicit none + logical :: ldiag + namelist /nam_nml1/ldiag +end module mod_nml1 + +module mod_interm + use mod_nml1 +end module mod_interm + +program ice_nml + use mod_nml1, ldiag_nml1 => ldiag + use mod_nml1, only : ldiag_only => ldiag + use mod_interm + implicit none + integer :: ilu = 10 + read(unit=ilu,nml=nam_nml1) + write(unit=*,nml=nam_nml1) + print *, ldiag + print *, ldiag_nml1 + print *, ldiag_only +end program ice_nml -- 2.35.3