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: 26410 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp5278953wrr; Sun, 27 Nov 2022 12:33:25 -0800 (PST) X-Google-Smtp-Source: AA0mqf6/MSWQikpvbz0Gqj0r+DtcO1jPpR9reQiwMNdkptKROfL8i7pUHmTIrjIyVjggpLu+uegl X-Received: by 2002:a05:6402:4504:b0:463:71ef:b9ce with SMTP id ez4-20020a056402450400b0046371efb9cemr35603862edb.75.1669581205044; Sun, 27 Nov 2022 12:33:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669581205; cv=none; d=google.com; s=arc-20160816; b=OOoK3Erx2ZW+MHc7JfOL35o5aV/RYW4cM/Au70z2faoS+nQzKX3WQQw3o+92qvBARq z9vgruXtC63wsNkD9MQ6qCLCbkH1CxajAQ3rtdNGH00nDBn3uttvKOCpS2Oo9Ob3hO+u T/qJFOYkBMwIuo10A26WsOFRbp+diOBIynNrsq/PLYqYgpqElL0zcweXJqnKB078M3Ed 7XR0UZA6YIF6zQuZYqUb0Md4e9wqPEnmQo6/eLXa6D++4JosmQPV8W4x/srCBVbwTjJn vlx51MvEokIHl7d0hjJmJ+IhXJ4FZE/yHOVeMvk854ZpAXbfzrSVsbwaUHXohybfTn2T zc3w== 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:ui-outboundreport :sensitivity:importance:date:subject:to:message-id:mime-version :dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=9cOebiA38BzUYW7aa45SfRx8SWJMgGsvDZSOZsgY6W8=; b=XVeAgM2RoRX6EjXATGXC7UZd1YzTjYDV3sq7mxp3t4jEuN5FxxSzBozgN+C0g6dWE9 rSVQNvvuGUIatrH3NyxoaoRbR9SdcO1zJ4aZyiPqaK0mvmXKzRfz5z17RZkbATLu3LrO 0z6GW0pQkKk7+9ngwmr8hpEMSqr2oiYuWXyYIGbb3yuJOMrANGYgfESIOGQP3cy71zrL 9d7JzBMZnznSELjntan0myKQd7JGcj9vajzV9aJfdWWJyyu0ZbCMxpSyLd/rZvk6AI2N MIuJ7sxkoadEc2fsn39nLkZ5LNrGBypAhddzWAxEeQ2eMWWEu7KioUIiZunSoz7yHWB0 0bNw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b="v/vHDVV6"; 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 (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id gs9-20020a1709072d0900b0078d9b2facaesi9900194ejc.339.2022.11.27.12.33.24 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 27 Nov 2022 12:33:25 -0800 (PST) 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="v/vHDVV6"; 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 127C5385802F for ; Sun, 27 Nov 2022 20:33:24 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 127C5385802F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1669581204; bh=9cOebiA38BzUYW7aa45SfRx8SWJMgGsvDZSOZsgY6W8=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=v/vHDVV6Ls+D/fIorkEK9BWaVlJ8ol5aMHzEZrK4Afi95eOnQ2f6AZxSda+ilMKS6 KIHsi4clx68n+PrpTagRAY0NbP54/80bI+3dQkyz+Ar1b01i9E/QaF2wq1CYdER8TG gTbiBAW/edKawgjTNvyLh4cqfvylZrFJgzCMygtk= 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+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750682782020480094?= X-GMAIL-MSGID: =?utf-8?q?1750682782020480094?= 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