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: 57326 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 6A59E3856956 for ; Sun, 4 Sep 2022 20:05:08 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6A59E3856956 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1662321908; bh=xEsuBd+skYoNHonmGPzW58oqZdcML7tgbHzYNVfLDfU=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=miMoV5JQXoy7H1z389CBud5blswWDrM2/E+8YlzJL+TK4y1YYHzbdk9HMWi62ypl0 vo8vUIyBRjnTSanHeDbU1bsiauIjmVq03VWHQQVbkcqqJxTXr/6GwIGp3lvI5TVjpd kx4mfhMIeoFTB/CfG9MkXXb7CoAhugtveDDBjDWA= 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: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SgVwun+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+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" 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