Debian Codegraph @

gcc/testsuite/gfortran.dg/dependent_decls_2.f90

raw
1 ! { dg-do run }
2 !
3 ! Fix for PR59104 in which the dependence on the old style function result
4 ! was not taken into account in the ordering of auto array allocation and
5 ! characters with dependent lengths.
6 !
7 ! Contributed by Tobias Burnus <[email protected]>
8 !
9 module m
10 implicit none
11 integer, parameter :: dp = kind([double precision::])
12 contains
13 function f(x)
14 integer, intent(in) :: x
15 real(dp) f(x/2)
16 real(dp) g(x/2)
17 integer y(size (f)+1) ! This was the original problem
18 integer z(size (f) + size (y)) ! Found in development of the fix
19 integer w(size (f) + size (y) + x) ! Check dummy is OK
20 integer :: l1(size(y))
21 integer :: l2(size(z))
22 integer :: l3(size(w))
23 f = 10.0
24 y = 1 ! Stop -Wall from complaining
25 z = 1; g = 1; w = 1; l1 = 1; l2 = 1; l3 = 1
26 if (size (f) .ne. 1) stop 1
27 if (size (g) .ne. 1) stop 2
28 if (size (y) .ne. 2) stop 3
29 if (size (z) .ne. 3) stop 4
30 if (size (w) .ne. 5) stop 5
31 if (size (l1) .ne. 2) stop 6 ! Check indirect dependencies
32 if (size (l2) .ne. 3) stop 7
33 if (size (l3) .ne. 5) stop 8
34
35 end function f
36 function e(x) result(f)
37 integer, intent(in) :: x
38 real(dp) f(x/2)
39 real(dp) g(x/2)
40 integer y(size (f)+1)
41 integer z(size (f) + size (y)) ! As was this.
42 integer w(size (f) + size (y) + x)
43 integer :: l1(size(y))
44 integer :: l2(size(z))
45 integer :: l3(size(w))
46 f = 10.0
47 y = 1; z = 1; g = 1; w = 1; l1 = 1; l2 = 1; l3 = 1
48 if (size (f) .ne. 2) stop 9
49 if (size (g) .ne. 2) stop 10
50 if (size (y) .ne. 3) stop 11
51 if (size (z) .ne. 5) stop 12
52 if (size (w) .ne. 9) stop 13
53 if (size (l1) .ne. 3) stop 14 ! Check indirect dependencies
54 if (size (l2) .ne. 5) stop 15
55 if (size (l3) .ne. 9) stop 16
56 end function
57 function d(x) ! After fixes to arrays, what was needed was known!
58 integer, intent(in) :: x
59 character(len = x/2) :: d
60 character(len = len (d)) :: line
61 character(len = len (d) + len (line)) :: line2
62 character(len = len (d) + len (line) + x) :: line3
63 ! Commented out lines give implicit type warnings with gfortran and nagfor
64 ! character(len = len (d)) :: line4 (len (line3))
65 character(len = len (line3)) :: line4 (len (line3))
66 ! character(len = size(len4, 1)) :: line5
67 line = repeat ("a", len (d))
68 line2 = repeat ("b", x)
69 line3 = repeat ("c", len (line3))
70 if (len (line2) .ne. x) stop 17
71 if (line3 .ne. "cccccccc") stop 18
72 d = line
73 line4 = line3
74 if (size (line4) .ne. 8) stop 19
75 if (any (line4 .ne. "cccccccc")) stop 20
76 end
77 end module m
78
79 program p
80 use m
81 implicit none
82 real(dp) y
83
84 y = sum (f (2))
85 if (int (y) .ne. 10) stop 21
86 y = sum (e (4))
87 if (int (y) .ne. 20) stop 22
88 if (d (4) .ne. "aa") stop 23
89 end program p