From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mout.gmx.net (mout.gmx.net [212.227.17.21]) by sourceware.org (Postfix) with ESMTPS id 612413856952; Sun, 4 Sep 2022 20:04:38 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 612413856952 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.net; s=badeba3b8450; t=1662321876; bh=gVHobUGSQN8jpmfxAvGcNPMY/SDXnMFZtKRgDD8+MLo=; h=X-UI-Sender-Class:From:To:Subject:Date; b=AgV452fmrIHRV9dcYblbLDsZkKiBgnlDdzmw762+vZGk2LZfk/LZZCH4sXqcmiwKQ zU8lSI9TYVCZgv/V670XbrANqag5jUyuZS8i6nWQzLMs2laBYgndnUe5CVjnrjbv80 aCMc9JQmJrZnapHGS+AahZEMyuGXLnciE9XrZQOo= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from [79.251.13.233] ([79.251.13.233]) by web-mail.gmx.net (3c-app-gmx-bs65.server.lan [172.19.170.209]) (via HTTP); Sun, 4 Sep 2022 22:04:36 +0200 MIME-Version: 1.0 Message-ID: From: Harald Anlauf To: fortran , gcc-patches Subject: Proxy ping [PATCH] PR fortran/100136 - ICE, regression, using flag -fcheck=pointer Content-Type: multipart/mixed; boundary=nika-4ec40f61-594f-4615-af83-66e7eafa3690 Date: Sun, 4 Sep 2022 22:04:36 +0200 Importance: normal Sensitivity: Normal X-Priority: 3 X-Provags-ID: V03:K1:27grsufhw/Gx370VrkjqtFjYsxxQlhdzeEDjJHpVid4m7VnrKv3vFlfhlCh27HKvvsErD jEv0QUyoWKrj8JZq397XAOyx6BRjxzNPgyeWImgHD0jJq4veN8QhVdxVLpbFNsXSx+BxffXiWoVn 4AkOeYWE2zWKPwq6hFkaHC3jN4yICzjUgL4yMDdvzrGCCojTMhhxbu3Cf/TY/yT6DB+XcT68uZOl WPx5chxoyhPtH1RaSCeMqnbGtaKJSjqsNjn9AxtFmVCjaNTtAtpqSZBje4pzHvYphi8a6wvRsKdT TI= X-UI-Out-Filterresults: notjunk:1;V03:K0:DOQ7xlPDAV4=:X7A62EHtXukC7Ob6dwvV7r YsuAW8ggmHPSiqQG8HLFngEiUxz4mSmhq8FYz0qK/1CLpfvxVarkZb3EbQHGilybC6bKObq00 1zTmu/khg1+ozJc8WzCoSGGFUNg0087eHJjphOI0VqyZxTnhcHXqAeye0RKrngP8Y5yzrsMwM NeJSBrH9mzOBryXPCLI3SLcoSUE0wQ0cT2vmsPZe6aH9qL+/8ohrYzy8akLSx82cBiVrQIIl/ MbddqwXd/w7MNMuAV1+PXXmNgeElsWjtq6rZdUPUeX21OzEq91v4u7RYidAS/WAa+t84ub+IP rgHRGVwANYHjJ3NO08G/KiGulRkWzWcaNylOQD/1D3LlIjmAHzZcf5tl0fAZJUsTEnxqvK4uw TgKPDQub3kthUxjddlrFQuw0sAEzKXwgRm/gj9iqmy+w5+MTLedkfnk0qWflN+YS9BUhXUk+O ifSZqkU3dGnh5WCX8j7IQIyVFGzMn5hy8IMntcyluAkFCvwTFC+hrgoPl340lR3OspsT/dqDt s+S2G5FdWv16PZs1iuhNGt4oOd0dXE6D3Gp2uFSxavJpMzUI106FvKLjLWr1qdb2fOuHXCDup IjRSmK9dZlZH31n1kIR5u+jg6zhDxPNFICw76KLiBWsI/wAQfC1Xoyvr4xr8asQr8GNJi7REF sv08sxuk5C58OAs2xdycVlW+1H81kZXv5dM8SgVwun+bl2AIsFCvpWF1y76xwWzxr/5/pfmLy xYz8MLf454MN7bunz32Rgtyp3WqvutmWwHeGZG2TD5kSU2W6OabiWodKlmXx5+KlkmY/VBny/ WK2WPi8 X-Spam-Status: No, score=-12.4 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,FREEMAIL_FROM,GIT_PATCH_0,KAM_SHORT,RCVD_IN_DNSWL_LOW,RCVD_IN_MSPIKE_H2,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 List-Id: --nika-4ec40f61-594f-4615-af83-66e7eafa3690 Content-Type: text/plain; charset=UTF-8 Dear all, said PR was addressed by Jose in https://gcc.gnu.org/pipermail/fortran/2021-April/055949.html but unfortunately his patch was never reviewed. IMHO the patch is mostly fine, with one small exception that it should use POINTER_TYPE_P (TREE_TYPE (tmp)), see PR and attached adjusted patch. Regtested on x86_64-pc-linux-gnu. Since this fixes a 11/12/13 regression on valid code, I'd like to commit this one on these branches, but would be glad to see an OK or LGTM from somebody else. (Jose says he's too busy currently.) Thanks, Harald --nika-4ec40f61-594f-4615-af83-66e7eafa3690 Content-Type: text/x-patch Content-Disposition: attachment; filename=PR100136.diff Content-Transfer-Encoding: quoted-printable =46rom 3ce0b852ddd91151a23baf8301b7aea5cc7d7ea0 Mon Sep 17 00:00:00 2001 From: =3D?UTF-8?q?Jos=3DC3=3DA9=3D20Rui=3D20Faustino=3D20de=3D20Sousa?=3D Date: Sun, 4 Sep 2022 21:53:09 +0200 Subject: [PATCH] Fortran: Fix ICE with -fcheck=3Dpointer [PR100136] gcc/fortran/ChangeLog: PR fortran/100136 * trans-expr.cc (gfc_conv_procedure_call): Add handling of pointer expressions. gcc/testsuite/ChangeLog: PR fortran/100136 * gfortran.dg/PR100136.f90: New test. =2D-- gcc/fortran/trans-expr.cc | 7 ++--- gcc/testsuite/gfortran.dg/PR100136.f90 | 39 ++++++++++++++++++++++++++ 2 files changed, 42 insertions(+), 4 deletions(-) create mode 100644 gcc/testsuite/gfortran.dg/PR100136.f90 diff --git a/gcc/fortran/trans-expr.cc b/gcc/fortran/trans-expr.cc index 13c3e7df45f..7895d034610 100644 =2D-- a/gcc/fortran/trans-expr.cc +++ b/gcc/fortran/trans-expr.cc @@ -7220,16 +7220,15 @@ gfc_conv_procedure_call (gfc_se * se, gfc_symbol *= sym, else goto end_pointer_check; + tmp =3D parmse.expr; if (fsym && fsym->ts.type =3D=3D BT_CLASS) { - tmp =3D build_fold_indirect_ref_loc (input_location, - parmse.expr); + if (POINTER_TYPE_P (TREE_TYPE (tmp))) + tmp =3D build_fold_indirect_ref_loc (input_location, tmp); tmp =3D gfc_class_data_get (tmp); if (GFC_DESCRIPTOR_TYPE_P (TREE_TYPE (tmp))) tmp =3D gfc_conv_descriptor_data_get (tmp); } - else - tmp =3D parmse.expr; /* If the argument is passed by value, we need to strip the INDIRECT_REF. */ diff --git a/gcc/testsuite/gfortran.dg/PR100136.f90 b/gcc/testsuite/gfortr= an.dg/PR100136.f90 new file mode 100644 index 00000000000..922af4aecc3 =2D-- /dev/null +++ b/gcc/testsuite/gfortran.dg/PR100136.f90 @@ -0,0 +1,39 @@ +! { dg-do run } +! { dg-options "-fcheck=3Dpointer" } +! { dg-shouldfail "Argument not allocated" } +! { dg-output "Fortran runtime error: Allocatable actual argument 'c_init= 2' is not allocated" } +! +! Tests fix for PR100136 +! +! Test cut down from PR58586 +! + +module test_pr58586_mod + implicit none + + type :: a + end type + + type :: c + type(a), allocatable :: a + end type + +contains + + subroutine add_class_c (d) + class(c), value :: d + end subroutine + + class(c) function c_init2() + allocatable :: c_init2 + end function + +end module test_pr58586_mod + +program test_pr58586 + use test_pr58586_mod + + ! This needs to execute, to see whether the segfault at runtime is reso= lved + call add_class_c(c_init2()) + +end program =2D- 2.35.3 --nika-4ec40f61-594f-4615-af83-66e7eafa3690--