From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mout.gmx.net (mout.gmx.net [212.227.17.20]) by sourceware.org (Postfix) with ESMTPS id 685483858D20; Thu, 9 Mar 2023 18:08:11 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 685483858D20 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmx.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmx.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.de; s=s31663417; t=1678385289; i=anlauf@gmx.de; bh=zDru3k7zJIZcyYZMJBYrdEKQl/EWorEcwg3NeVbSf0A=; h=X-UI-Sender-Class:From:To:Subject:Date; b=nEFhcU6ntWGrgEmRKxso66aZIRbh8OMwkVw4m9P3n6WYQNslevMSZmEqKJIaJpmps qi7jJL1VcP9WagwS8cqbwDE85ACTxs03VtpryWNoyi4SNZhwZYyEKc03zNfUw/hN8P UZfKHT4nHwDDZ10zyXFkRzbWmeStY0m3J1FoCG9cTXx5X6u3GlnlgiRmSC/3QRmqhV 0VIDTkzCStei87N58X7GPz7vheNq23T3pRAiVgKCfBjPSFpU0nrK0qCwrVlBrfSM2C FdJr0ghgRra2uIY1RzRrQ97gyPrcuEd5Q4d887w1+3lJID42AEHYKj8l/iJn3B/4dC TWAFiTtfOjRXA== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from [93.207.86.196] ([93.207.86.196]) by web-mail.gmx.net (3c-app-gmx-bap32.server.lan [172.19.172.102]) (via HTTP); Thu, 9 Mar 2023 19:08:09 +0100 MIME-Version: 1.0 Message-ID: From: Harald Anlauf To: fortran , gcc-patches Subject: [PATCH] Fortran: fix ICE with bind(c) in block data [PR104332] Content-Type: multipart/mixed; boundary=rekceb-230d93a3-f268-4a6f-9c12-b631d95a6003 Date: Thu, 9 Mar 2023 19:08:09 +0100 Importance: normal Sensitivity: Normal X-Priority: 3 X-Provags-ID: V03:K1:z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m/UZfFfbA9mNuslgGPAkGR sSsIbS61a3shueeeL9OcnLoFYa/D3k8euBva2ykSZRuumdc69CYkrNC89x8DAM64Yg2vTlXEY GBAixio0SeUsdWnv2Rty+vqg== X-Spam-Status: No, score=-12.8 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_H2,SPF_HELO_NONE,SPF_PASS,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 List-Id: --rekceb-230d93a3-f268-4a6f-9c12-b631d95a6003 Content-Type: text/plain; charset=UTF-8 Dear all, the attached almost obvious patch fixes a NULL pointer dereference in a check of a symbol with the bind(c) attribute. Regtested on x86_64-pc-linux-gnu. OK for mainline? This PR is marked as 10/11/12/13 regression, thus it should qualify for a backport. It's simple enough anyway. Thanks, Harald --rekceb-230d93a3-f268-4a6f-9c12-b631d95a6003 Content-Type: text/x-patch Content-Disposition: attachment; filename=pr104332.diff Content-Transfer-Encoding: quoted-printable =46rom ef96d7d360c088d68e3b405401bdb8b589d562f2 Mon Sep 17 00:00:00 2001 From: Harald Anlauf Date: Thu, 9 Mar 2023 18:59:08 +0100 Subject: [PATCH] Fortran: fix ICE with bind(c) in block data [PR104332] gcc/fortran/ChangeLog: PR fortran/104332 * resolve.cc (resolve_symbol): Avoid NULL pointer dereference while checking a symbol with the BIND(C) attribute. gcc/testsuite/ChangeLog: PR fortran/104332 * gfortran.dg/bind_c_usage_34.f90: New test. =2D-- gcc/fortran/resolve.cc | 4 ++-- gcc/testsuite/gfortran.dg/bind_c_usage_34.f90 | 21 +++++++++++++++++++ 2 files changed, 23 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/gfortran.dg/bind_c_usage_34.f90 diff --git a/gcc/fortran/resolve.cc b/gcc/fortran/resolve.cc index 2780c82c798..46585879ddc 100644 =2D-- a/gcc/fortran/resolve.cc +++ b/gcc/fortran/resolve.cc @@ -15933,8 +15933,8 @@ resolve_symbol (gfc_symbol *sym) /* First, make sure the variable is declared at the module-level scope (J3/04-007, Section 15.3). */ - if (sym->ns->proc_name->attr.flavor !=3D FL_MODULE && - sym->attr.in_common =3D=3D 0) + if (!(sym->ns->proc_name && sym->ns->proc_name->attr.flavor =3D=3D = FL_MODULE) + && !sym->attr.in_common) { gfc_error ("Variable %qs at %L cannot be BIND(C) because it " "is neither a COMMON block nor declared at the " diff --git a/gcc/testsuite/gfortran.dg/bind_c_usage_34.f90 b/gcc/testsuite= /gfortran.dg/bind_c_usage_34.f90 new file mode 100644 index 00000000000..40c8e9363cf =2D-- /dev/null +++ b/gcc/testsuite/gfortran.dg/bind_c_usage_34.f90 @@ -0,0 +1,21 @@ +! { dg-do compile } +! PR fortran/104332 - ICE with bind(c) in block data +! Contributed by G. Steinmetz + +block data + bind(c) :: a ! { dg-error "cannot be BIND\\(C\\)" } +end + +block data aa + real, bind(c) :: a ! { dg-error "cannot be BIND\\(C\\)" } +end + +block data bb + real :: a ! { dg-error "cannot be BIND\\(C\\)" } + bind(c) :: a +end + +block data cc + common /a/ x + bind(c) :: /a/ +end =2D- 2.35.3 --rekceb-230d93a3-f268-4a6f-9c12-b631d95a6003--