From patchwork Sun Nov 27 20:32:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Harald Anlauf X-Patchwork-Id: 1709444 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.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+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: legolas.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=T+XC4twZ; 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 ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4NL0fV57ZQz23nT for ; Mon, 28 Nov 2022 07:33:05 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id CE52A3858439 for ; Sun, 27 Nov 2022 20:33:00 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org CE52A3858439 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1669581180; bh=9cOebiA38BzUYW7aa45SfRx8SWJMgGsvDZSOZsgY6W8=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=T+XC4twZOUu4Toz6dqs+2+16IxUmZA2liL9MJ52Mtn/s02jZE7fTORBbmdvIikHQm BWArshfkjHcDbtpLgy1csfn+shZm7T+2VLYrfRLrNNi5sYinYpPgEPfW32ZCYr6FiQ bIysLbetkcVxvG5yHTxBJLaa0MbTL3WFwOiPy3bU= 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.22]) by sourceware.org (Postfix) with ESMTPS id 6CEAE3858D3C; Sun, 27 Nov 2022 20:32:39 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 6CEAE3858D3C X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from [93.207.88.249] ([93.207.88.249]) by web-mail.gmx.net (3c-app-gmx-bap47.server.lan [172.19.172.117]) (via HTTP); Sun, 27 Nov 2022 21:32:37 +0100 MIME-Version: 1.0 Message-ID: To: fortran , gcc-patches Subject: [PATCH] Fortran: ICE with elemental and dummy argument with VALUE attribute [PR107819] Date: Sun, 27 Nov 2022 21:32:37 +0100 Importance: normal Sensitivity: Normal X-Priority: 3 X-Provags-ID: V03:K1:cyoRhX30m78JeiSSreckdAhWDZ2WooBLSlzXB2fLr1gUV2/vof6OhCGNLoj8Q8gJQ7pen V4clgRPeOZce5mpRTm/eBhO32qTci3ruLFXU0OQAZs79Sv8jAxZtrBw9NDNS0ubJsWOZ1PJAWlIu Z358g0mSlwLuwp1T3cZKgiy07MX8vdPIzhpXBDrOHOaiB/WBfTwRZ3MFbzdNWJGXiA3O427U485B vcIeKezN4SRhP0ETv/DGv/5jU97FoILeofkfW+BZf8VbIcc2MqjypCToSJRLFL249RdTOnZQPukq 4k= UI-OutboundReport: notjunk:1;M01:P0:cb5F29Gt7hI=;yijXy1XKCkegqG/mo+YopQQOHhI 2vnmGxFlLfTvHuIeY0zjM9/xfKjLof5oEFGvu2bSmHMBBWSN5a3TbEXsJDfEng59LYB4r6xu8 aTXMFKIkZurjX8WccRZiUI5f1A4gpsoQhJ/fT4wtpzcrZWF06Wwu2ZPPsmWXwFov/38Hc51ni 9ZHLSw8eSjR9lZ6HluMJ/bvLOpis83AGYxsY949pcqge5QRrM4yKc5f/SLJ2k92KqTmgm/y4C aR0B+shS6Seu3J7RAMdlvb9noEVqcteWa3BWoo70wISVoh7kdXQSlHtXcWiUQ/iPDobLorScp 4ggrc/mvS3o4dr5d0RqcVisIoRRp+HiLfuiogTSwW8HZxL+VrcthWnPpNYjmjM9ryWma/pEel zuGV8Qr4ywg1F/clXqOknMt43+jnl0DhKErhPSboSFtAi1IcPyTOIFOrqIFLKGHojTDCAzk1B 4ONbG5cNBECkTwSEst07FUZLdiOe+W7U5HAG3zcisVYnAJ6g8tY4dRRMUMAZ0H1/tOU4McgfT K0fFgK3SF3xiUFcIwS86buiqi1jgI4fj0x3DxUjYDXgXY+xJq7GBcY3GGbAlhDGEZnm9G9kyr VXTaGRlV1iqJ+gzNZ11HclpwI1U07lPSFq+Bx2XcS06BzlzGMQx0ecBWvHy94saNhpGnjViGv 2vS4UfZpKZYz2C06EcJU5itzS94O3vs+F1uX3uICsnHxoFKkKGNkFTF4/JLTsLRpvJ6dPID8A LUDvuFsb+Lbp34WOpJiEOUxqF2oW3UTHKSof6xuW1wo/miX2MkJSwjb6QO3cdkWSwF0DP5yek ZLBJCT1/GGY6eT1RlkJo5hXw== X-Spam-Status: No, score=-11.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_BARRACUDACENTRAL, 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 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+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" Dear Fortranners, in dependency checking of arguments of elemental prodecures we should treat dummy arguments with the value attribute as implicitly having intent(in). This is simple and obvious. The PR by Gerhard provides a series of testcases that are either valid (like the one in the attached patch), or arguably non-conforming. The issue is related to the standard prescribing a temporary (in standardese language) for the argument with the value attribute, while the elemental attribute prescribes an application order. Playing with other compiler brands, there seemed to be an obvious discrepancy between NAG and Intel on the one side and Intel on the other. Steve Lionel attributed this to non-conformance for the discussed case (see link in PR). I therefore decided to only use a conforming testcase for the testsuite, as this is sufficient to check for the fix for the ICE. Regtested on x86_64-pc-linux-gnu. OK for mainline? Thanks, Harald From c6f9d47f2e631a7ace71466ba6ec6f323d791b1b Mon Sep 17 00:00:00 2001 From: Harald Anlauf Date: Sun, 27 Nov 2022 21:10:18 +0100 Subject: [PATCH] Fortran: ICE with elemental and dummy argument with VALUE attribute [PR107819] gcc/fortran/ChangeLog: PR fortran/107819 * trans-stmt.cc (gfc_conv_elemental_dependencies): In checking for elemental dependencies, treat dummy argument with VALUE attribute as implicitly having intent(in). gcc/testsuite/ChangeLog: PR fortran/107819 * gfortran.dg/elemental_dependency_7.f90: New test. --- gcc/fortran/trans-stmt.cc | 1 + .../gfortran.dg/elemental_dependency_7.f90 | 28 +++++++++++++++++++ 2 files changed, 29 insertions(+) create mode 100644 gcc/testsuite/gfortran.dg/elemental_dependency_7.f90 diff --git a/gcc/fortran/trans-stmt.cc b/gcc/fortran/trans-stmt.cc index fd6d294147e..b288f1f9050 100644 --- a/gcc/fortran/trans-stmt.cc +++ b/gcc/fortran/trans-stmt.cc @@ -264,6 +264,7 @@ gfc_conv_elemental_dependencies (gfc_se * se, gfc_se * loopse, if (e->expr_type == EXPR_VARIABLE && e->rank && fsym && fsym->attr.intent != INTENT_IN + && !fsym->attr.value && gfc_check_fncall_dependency (e, fsym->attr.intent, sym, arg0, check_variable)) { diff --git a/gcc/testsuite/gfortran.dg/elemental_dependency_7.f90 b/gcc/testsuite/gfortran.dg/elemental_dependency_7.f90 new file mode 100644 index 00000000000..ad45ea5271b --- /dev/null +++ b/gcc/testsuite/gfortran.dg/elemental_dependency_7.f90 @@ -0,0 +1,28 @@ +! { dg-do run } +! PR fortran/107819 - ICE in gfc_check_argument_var_dependency +! Contributed by G.Steinmetz +! +! Note: the testcase is considered non-conforming for m>1 due to aliasing + +program p + implicit none + integer, parameter :: m = 1 + integer :: i + integer :: a(m) = [(-i,i=1,m)] + integer :: n(m) = [(i,i=m,1,-1)] + integer :: b(m) + b = a + call s (a(n), a) ! { dg-warning "might interfere with actual argument" } + + ! Compare to separate application of subroutine in element order + do i = 1, size (b) + call s (b(n(i)), b(i)) + end do + if (any (a /= b)) stop 1 +contains + elemental subroutine s (x, y) + integer, value :: x + integer, intent(out) :: y + y = x + end +end -- 2.35.3