Debian Codegraph @

gcc/testsuite/gfortran.dg/assumed_rank_25.f90

raw
1 ! { dg-do run }
2 ! { dg-additional-options "-fcheck=bounds" }
3 !
4 ! PR fortran/117774 - passing imaginary part of complex array to assumed rank dummy
5
6 module mod
7 implicit none
8 contains
9 subroutine foo(r, s1, s2)
10 real, intent(in) :: r(..) ! ASSUMED-RANK DUMMY
11 real, intent(in), optional :: s1(:)
12 real, intent(in), optional :: s2(:,:)
13 select rank (r)
14 rank (1)
15 ! print *, r
16 if (present (s1)) then
17 if (any (r /= s1)) stop 1
18 end if
19 rank (2)
20 ! print *, r
21 if (present (s2)) then
22 if (any (r /= s2)) stop 2
23 end if
24 end select
25 end subroutine
26 end module
27
28 program p
29 use mod
30 implicit none
31 real :: re1(3), im1(3)
32 real :: re2(3,7), im2(3,7)
33 complex :: z1(3), z2 (3,7)
34 integer :: i, j
35
36 re1 = [(2*i-1,i=1,size(re1))]
37 im1 = [(2*i ,i=1,size(im1))]
38 z1 = cmplx (re1,im1)
39 call foo (z1 % re, re1)
40 call foo (z1 % im, im1)
41 call foo (z1(2:)% re, re1(2:))
42 call foo (z1(2:)% im, im1(2:))
43
44 re2 = reshape ([ (re1+10*j, j=1,7)], shape (re2))
45 im2 = reshape ([ (im1+10*j, j=1,7)], shape (im2))
46 z2 = cmplx (re2,im2)
47 call foo (z2 % re, s2=re2)
48 call foo (z2 % im, s2=im2)
49 call foo (z2(2:,3:)% re, s2=re2(2:,3:))
50 call foo (z2(2:,3:)% im, s2=im2(2:,3:))
51 end