https://gcc.gnu.org/g:5fca6b214a6004002e14aeb17a0e90a7ce64d997
commit 5fca6b214a6004002e14aeb17a0e90a7ce64d997 Author: Mikael Morin <mik...@gcc.gnu.org> Date: Tue Jul 29 21:52:48 2025 +0200 fortran: Ajout test gcc/testsuite/ChangeLog: * gfortran.dg/class_elemental_1.f90: New test. Diff: --- gcc/testsuite/gfortran.dg/class_elemental_1.f90 | 34 +++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/gcc/testsuite/gfortran.dg/class_elemental_1.f90 b/gcc/testsuite/gfortran.dg/class_elemental_1.f90 new file mode 100644 index 000000000000..43ebd0419170 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/class_elemental_1.f90 @@ -0,0 +1,34 @@ +! { dg-do run } +! +! The polymorphic function result as actual argument used to force the loop +! bounds around the elemental call, altering access to the other arrays. + +program p + implicit none + type :: t + integer :: i + end type + type :: u + integer :: i, a + end type + type(u) :: accum(5) + integer :: a(3:7), k + a = [ (k*k, k=1,5) ] + call s(accum, f(), a) + ! print *, accum%i + ! print *, accum%a + if (any(accum%i /= accum%a)) error stop 1 +contains + elemental subroutine s(l, c, a) + type(u) , intent(out) :: l + class(t) , intent(in) :: c + integer , intent(in) :: a + l%i = c%i + l%a = a + end subroutine + function f() + class(t), allocatable :: f(:) + allocate(f(-1:3)) + f%i = [ (k*k, k=1,5) ] + end function +end program