From patchwork Sun Apr 18 15:13:05 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Jos=C3=A9_Rui_Faustino_de_Sousa?= X-Patchwork-Id: 1467619 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=gcc-patches-bounces@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=mqb0y0UC; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4FNYP21T5pz9vFm for ; Mon, 19 Apr 2021 01:13:24 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id ADA593943541; Sun, 18 Apr 2021 15:13:19 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org ADA593943541 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1618758799; bh=8V9w9kc3lRra1a0S8ixcsgwuUsdJNZ7uEtDxiJ5skLg=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=mqb0y0UCYD4uysTC0RNq0xCzXmPsaRhpuc3hnn7+3T0bGYOIukz5FTiYkvYyd25mH /GWyDcljQVG+i6x3oHO61vvIe2HpfbVFmZUTq4KWPgP0sSsE7RMQdkeQf+EMxdJGDL JuhHRMQTsoRbURZSNOMJTXlK9dh5YOQyouIHZxZc= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wm1-x32e.google.com (mail-wm1-x32e.google.com [IPv6:2a00:1450:4864:20::32e]) by sourceware.org (Postfix) with ESMTPS id A3D593854804; Sun, 18 Apr 2021 15:13:07 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org A3D593854804 Received: by mail-wm1-x32e.google.com with SMTP id o9-20020a1c41090000b029012c8dac9d47so9736915wma.1; Sun, 18 Apr 2021 08:13:07 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:to:from:subject:message-id:date:user-agent :mime-version:content-language; bh=8V9w9kc3lRra1a0S8ixcsgwuUsdJNZ7uEtDxiJ5skLg=; b=c8WxMf79niYyvrJZDN7rbo1/c2gfTRqdbIjaravm5RmTNUg0gw9JX1B8POsEVo/xtP XiEVDf0W56ZOW314WQGYLC/UJS+tPJIyHSSfwsvvc0yxzR3o/qjq0Q5UOzsqNSS9sJPY jnzSSA7XANYLGNF4DSDiodAIurY9+2NpdXxtiMuyQvjPQ8l+X3RPGKkmDZZXI0iyRehe nTRZzDiBSMvRGMJOALK73B77FCDf3LIoBeFfMswH3JntZppPDtExeljdVMw9s9N4cbMc NI2QK+uld1xRZzLcC8lHKMpi8uxO/ZxeHSyZH0txHEKcxZg05Yfp7hnQeO6iWelLaJ7Z kCzQ== X-Gm-Message-State: AOAM533I4O7YtCRqscza8t1RzFJsdNjDB5rH6/+8+pj+6Wd9v+wF4V4k oR+FN38JVFmbtFnbiwlB4KM+qkVRtGw= X-Google-Smtp-Source: ABdhPJyXosnTbnqrdfb66Tz3AVMyXc9f6Zqssx5jKhTGPzdZaKhN9ZE/cDrIVyxHbdNOvBVQfRzIVQ== X-Received: by 2002:a05:600c:3397:: with SMTP id o23mr17010589wmp.26.1618758786651; Sun, 18 Apr 2021 08:13:06 -0700 (PDT) Received: from ?IPv6:2001:8a0:7d5c:3000:5dde:5a80:434a:4f82? ([2001:8a0:7d5c:3000:5dde:5a80:434a:4f82]) by smtp.googlemail.com with ESMTPSA id l5sm16922940wmh.0.2021.04.18.08.13.05 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 18 Apr 2021 08:13:06 -0700 (PDT) To: fortran@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [Patch, fortran] PR fortran/100136 - ICE, regression, using flag -fcheck=pointer Message-ID: Date: Sun, 18 Apr 2021 15:13:05 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 Content-Language: en-US X-Spam-Status: No, score=-12.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) 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: =?utf-8?q?Jos=C3=A9_Rui_Faustino_de_Sousa_via_Gcc-patches?= From: =?utf-8?q?Jos=C3=A9_Rui_Faustino_de_Sousa?= Reply-To: =?utf-8?q?Jos=C3=A9_Rui_Faustino_de_Sousa?= Errors-To: gcc-patches-bounces@gcc.gnu.org Sender: "Gcc-patches" Hi All! Proposed patch to: PR100136 - ICE, regression, using flag -fcheck=pointer Patch tested only on x86_64-pc-linux-gnu. Add handling for pointer expressions. Thank you very much. Best regards, José Rui Fortran: Fix ICE with -fcheck=pointer [PR100136] gcc/fortran/ChangeLog: PR fortran/100136 * trans-expr.c (gfc_conv_procedure_call): Add handling of pointer expressions. gcc/testsuite/ChangeLog: PR fortran/100136 * gfortran.dg/PR100136.f90: New test. diff --git a/gcc/fortran/trans-expr.c b/gcc/fortran/trans-expr.c index 213f32b0a67..249b3904cdb 100644 --- a/gcc/fortran/trans-expr.c +++ b/gcc/fortran/trans-expr.c @@ -6782,16 +6782,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 (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..931a4796846 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/PR100136.f90 @@ -0,0 +1,40 @@ +! { 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 +