public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r13-4375] Fortran: ICE with elemental and dummy argument with VALUE attribute [PR107819]
@ 2022-11-28 18:54 Harald Anlauf
  0 siblings, 0 replies; only message in thread
From: Harald Anlauf @ 2022-11-28 18:54 UTC (permalink / raw)
  To: gcc-cvs

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

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-11-28 18:54 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-28 18:54 [gcc r13-4375] Fortran: ICE with elemental and dummy argument with VALUE attribute [PR107819] Harald Anlauf

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).