From patchwork Sun Sep 4 20:04:36 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Harald Anlauf X-Patchwork-Id: 958 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:ecc5:0:0:0:0:0 with SMTP id s5csp1663205wro; Sun, 4 Sep 2022 13:05:24 -0700 (PDT) X-Google-Smtp-Source: AA6agR4vUL3ntappXuz+0DaGoixYlQRObnhaZfuPGKCSiC2W0Jkx5ZnvGXLhN2PWk5zP6NfD0eWS X-Received: by 2002:a17:907:2c4f:b0:741:5b68:e2dd with SMTP id hf15-20020a1709072c4f00b007415b68e2ddmr18486432ejc.513.1662321923855; Sun, 04 Sep 2022 13:05:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662321923; cv=none; d=google.com; s=arc-20160816; b=GTMosL5ihasG7v/uv7xIITuLr0YQ2ZslcEoD0x2Mjmc15SFRgmndsold0uKqPugI0c GQ8Ni63MICEsQCtqi4XFlh/P+tvdBE7Crlz/9iK6vue3ZIqKmJM6VeIgR/T5zMdru07H E+0WlBElB7HqHbnzDXqMAFSV4eXu73csLcCXBk2fumtqiHWipKzEJwJMXQwmm3ztLeTc 5q/5LLAj4gLXV9nWsmo9Kd6eHx/L1zDCFMihDrzcgkAEZNAbYc0ATitzlsGJIDTlBPX0 7HGpqLcefy0WqtprqfizkDIPrgeArGULO1n7kfKxYFg8CH9b6tujpWxgD/Ev5NUoUit6 Al9Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence:sensitivity :importance:date:subject:to:message-id:mime-version:dmarc-filter :delivered-to:dkim-signature:dkim-filter; bh=xEsuBd+skYoNHonmGPzW58oqZdcML7tgbHzYNVfLDfU=; b=rriW4ThvJtFOJA6z6XjgRaqcJysMTwkgNYVrs1YKQkdz8tvoZEG5e+y61ZoBDyXlvU r+NH4dBPldfgHRy0ZN+cmIiRSMvH2uc0Eoqp8YORkkZRWrgz7mFw0Q1h0N87vas2FfP2 GAtF52KVrION4Qj+UuEY5OM7NwKcI69EyUs1KH0Pfe2I+CTiwglzBZ80f7M3XX38RRMO GbtWR1m0EagOKcpk4VYvRIK2wsXxKEOzDgSBdaqgXy8zomvVjJA7S3nODDY32/NJJD8Y gXr7qkFtiIAj4sy6k3IEzzg15OaWL2gcW7QDLNZfj47sLY/L2avNiSbhamz1d2+5Ovdb 1LxA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=EXXTj7fE; 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 sourceware.org (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id z6-20020a056402274600b00447726f8e2asi7212099edd.48.2022.09.04.13.05.23 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Sep 2022 13:05:23 -0700 (PDT) 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=EXXTj7fE; 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 A72523856965 for ; Sun, 4 Sep 2022 20:05:22 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A72523856965 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1662321922; bh=xEsuBd+skYoNHonmGPzW58oqZdcML7tgbHzYNVfLDfU=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=EXXTj7fEULKzueoSOAipztgiGb8uAC9z6X+x2TL6Vij1ddffybZO2wwKKa/r15F8P dCF0A7WL98RkpTUIQ00xwoMr8urCYyM6DEvIAHHpd26mU0SQvpvn468Yt9aVOCmt0p 3UOaUF+s8M5JA/pKnTTSzJ5ZsI332fhNl2KEULVw= 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.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 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: To: fortran , gcc-patches Subject: Proxy ping [PATCH] PR fortran/100136 - ICE, regression, using flag -fcheck=pointer 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 X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Harald Anlauf via Gcc-patches From: Harald Anlauf Reply-To: Harald Anlauf Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1743070873414317547?= X-GMAIL-MSGID: =?utf-8?q?1743070873414317547?= 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 From 3ce0b852ddd91151a23baf8301b7aea5cc7d7ea0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Rui=20Faustino=20de=20Sousa?= Date: Sun, 4 Sep 2022 21:53:09 +0200 Subject: [PATCH] Fortran: Fix ICE with -fcheck=pointer [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. --- 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 --- 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 = parmse.expr; if (fsym && fsym->ts.type == BT_CLASS) { - tmp = build_fold_indirect_ref_loc (input_location, - parmse.expr); + if (POINTER_TYPE_P (TREE_TYPE (tmp))) + tmp = build_fold_indirect_ref_loc (input_location, tmp); tmp = gfc_class_data_get (tmp); if (GFC_DESCRIPTOR_TYPE_P (TREE_TYPE (tmp))) tmp = gfc_conv_descriptor_data_get (tmp); } - else - tmp = 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/gfortran.dg/PR100136.f90 new file mode 100644 index 00000000000..922af4aecc3 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/PR100136.f90 @@ -0,0 +1,39 @@ +! { dg-do run } +! { dg-options "-fcheck=pointer" } +! { dg-shouldfail "Argument not allocated" } +! { dg-output "Fortran runtime error: Allocatable actual argument 'c_init2' 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 resolved + call add_class_c(c_init2()) + +end program -- 2.35.3