https://gcc.gnu.org/g:4071656c8bae012aa5d9fabd9302c50c5ede000a

commit 4071656c8bae012aa5d9fabd9302c50c5ede000a
Author: Mikael Morin <mik...@gcc.gnu.org>
Date:   Fri Jul 25 11:54:03 2025 +0200

    testsuite: Ajout test
    
            PR fortran/121185
    
    gcc/testsuite/ChangeLog:
    
            * gfortran.dg/assign_13.f90: New test.

Diff:
---
 gcc/testsuite/gfortran.dg/assign_13.f90 | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/gcc/testsuite/gfortran.dg/assign_13.f90 
b/gcc/testsuite/gfortran.dg/assign_13.f90
new file mode 100644
index 000000000000..262ade0997aa
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/assign_13.f90
@@ -0,0 +1,25 @@
+! { dg-do run }
+!
+! PR fortran/121185
+! The assignment to Y%X in CHECK_T was using a polymorphic array access on the
+! left hand side, using the virtual table of Y.
+
+program p
+  implicit none
+  type t
+     complex, allocatable :: x(:)
+  end type t
+  real :: trace = 2.
+  type(t) :: z
+  z%x = [1,2] * trace
+  call check_t (z)
+contains
+  subroutine check_t (y)
+    class(t) :: y
+    ! print *, y% x
+    if (any(y%x /= [2., 4.])) error stop 11
+    y%x = y%x / trace
+    ! print *, y% x
+    if (any(y%x /= [1., 2.])) error stop 12
+  end subroutine
+end

Reply via email to