Debian Codegraph @

gcc/testsuite/gfortran.dg/assumed_rank_9.f90

raw
1 ! { dg-do run }
2 ! { dg-additional-sources assumed_rank_8_c.c }
3 !
4 ! PR fortran/48820
5 !
6 ! Scalars to assumed-rank tests
7 !
8 program main
9 implicit none
10
11 type t
12 integer :: i
13 end type t
14
15 interface
16 subroutine check (x)
17 integer :: x(..)
18 end subroutine check
19 subroutine check2 (x)
20 import t
21 class(t) :: x(..)
22 end subroutine check2
23 end interface
24
25 integer :: j
26
27 type(t), target :: y
28 class(t), allocatable, target :: yac
29 type(t), pointer :: ypt
30
31 y%i = 489
32 allocate (yac)
33 yac%i = 489
34 j = 0
35 call fc()
36 call fc(null(yac))
37 call fc(y)
38 call fc(yac)
39 if (j /= 2) STOP 1
40
41 j = 0
42 ! call gc(null(yac)) ! ICE
43 call gc(y)
44 call gc(yac)
45 deallocate (yac)
46 call gc(yac)
47 if (j /= 2) STOP 2
48
49 j = 0
50 call hc(yac)
51 allocate (yac)
52 yac%i = 489
53 call hc(yac)
54 if (j /= 1) STOP 3
55
56 j = 0
57 call ft()
58 call ft(null(yac))
59 call ft(y)
60 call ft(yac)
61 if (j /= 2) STOP 4
62
63 j = 0
64 call gt(null(ypt))
65 ! call gt(null(yac)) ! ICE
66 call gt(y)
67 call gt(yac)
68 deallocate (yac)
69 call gt(yac)
70 if (j /= 2) STOP 5
71
72 j = 0
73 call ht(yac)
74 allocate (yac)
75 yac%i = 489
76 call ht(yac)
77 if (j /= 1) STOP 6
78 deallocate (yac)
79
80 contains
81
82 subroutine fc (x)
83 class(t), optional :: x(..)
84
85 if (.not. present (x)) return
86 if (.not. SAME_TYPE_AS (x, yac)) STOP 7
87 if (rank (x) /= 0) STOP 1
88 call check2 (x)
89 j = j + 1
90 end subroutine
91
92 subroutine gc (x)
93 class(t), pointer, intent(in) :: x(..)
94
95 if (.not. associated (x)) return
96 if (.not. SAME_TYPE_AS (x, yac)) STOP 8
97 if (rank (x) /= 0) STOP 9
98 call check2 (x)
99 j = j + 1
100 end subroutine
101
102 subroutine hc (x)
103 class(t), allocatable :: x(..)
104
105 if (.not. allocated (x)) return
106 if (.not. SAME_TYPE_AS (x, yac)) STOP 10
107 if (rank (x) /= 0) STOP 2
108 call check2 (x)
109 j = j + 1
110 end subroutine
111
112 subroutine ft (x)
113 type(t), optional :: x(..)
114
115 if (.not. present (x)) return
116 if (.not. SAME_TYPE_AS (x, yac)) STOP 11
117 if (rank (x) /= 0) STOP 3
118 call check2 (x)
119 j = j + 1
120 end subroutine
121
122 subroutine gt (x)
123 type(t), pointer, intent(in) :: x(..)
124
125 if (.not. associated (x)) return
126 if (.not. SAME_TYPE_AS (x, yac)) STOP 12
127 if (rank (x) /= 0) STOP 13
128 call check2 (x)
129 j = j + 1
130 end subroutine
131
132 subroutine ht (x)
133 type(t), allocatable :: x(..)
134
135 if (.not. allocated (x)) return
136 if (.not. SAME_TYPE_AS (x, yac)) STOP 14
137 if (rank (x) /= 0) STOP 4
138 call check2 (x)
139 j = j + 1
140 end subroutine
141
142 end program main