public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Harald Anlauf <anlauf@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc r13-4375] Fortran: ICE with elemental and dummy argument with VALUE attribute [PR107819]
Date: Mon, 28 Nov 2022 18:54:11 +0000 (GMT)	[thread overview]
Message-ID: <20221128185411.F01F83858C62@sourceware.org> (raw)

https://gcc.gnu.org/g:07b9bcc1d1484f8f1c850ff14db678fb6b1e4d36

commit r13-4375-g07b9bcc1d1484f8f1c850ff14db678fb6b1e4d36
Author: Harald Anlauf <anlauf@gmx.de>
Date:   Sun Nov 27 21:10:18 2022 +0100

    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.

Diff:
---
 gcc/fortran/trans-stmt.cc                          |  1 +
 .../gfortran.dg/elemental_dependency_7.f90         | 28 ++++++++++++++++++++++
 2 files changed, 29 insertions(+)

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

                 reply	other threads:[~2022-11-28 18:54 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20221128185411.F01F83858C62@sourceware.org \
    --to=anlauf@gcc.gnu.org \
    --cc=gcc-cvs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).