Debian Codegraph @

gcc/testsuite/gfortran.dg/null_actual_6.f90

raw
1 ! { dg-do run }
2 ! { dg-additional-options "-fcheck=bounds" }
3 !
4 ! PR fortran/104819 - passing of NULL() actual argument to character dummy
5
6 program p
7 implicit none
8 character(kind=1,len=10), pointer :: c => NULL()
9 character(kind=1,len=:), pointer :: d => NULL()
10 character(kind=1,len=10), pointer :: c1(:) => NULL()
11 character(kind=1,len=:), pointer :: d1(:) => NULL()
12 character(kind=4,len=10), pointer :: c4(:) => NULL()
13 character(kind=4,len=:), pointer :: d4(:) => NULL()
14
15 ! scalar character variables:
16 ! kind=1, assumed length
17 call rank0_al (null(c))
18 call rank0_al (c)
19 call arank_al (null(c))
20 call arank_al (c)
21 call rank0_alb(null(c))
22 call rank0_alb(c)
23
24 ! kind=1, fixed length
25 call rank0_fl (null(c))
26 call rank0_fl (null())
27 call rank0_fl (c)
28 call arank_fl (null(c))
29 call arank_fl (c)
30 call rank0_flb(null(c))
31 call rank0_flb(c)
32
33 ! kind=1, deferred length
34 call rank0_dl (null(d))
35 call rank0_dl (null())
36 call rank0_dl (d)
37 call arank_dl (null(d)) ! <- this crashes nagfor 7.2
38 call arank_dl (d)
39 call rank0_dlb(null(d))
40 call rank0_dlb(null())
41
42 ! rank-1 character variables:
43 ! kind=1, assumed length
44 call rank1_al (null(c1))
45 call rank1_al (c1)
46 call arank_al (null(c1))
47 call arank_al (c1)
48 call rank1_alb(null(c1))
49 call rank1_alb(c1)
50
51 ! kind=1, fixed length
52 call rank1_fl (null(c1))
53 call rank1_fl (null())
54 call rank1_fl (c1)
55 call arank_fl (null(c1))
56 call arank_fl (c1)
57 call rank1_flb(null(c1))
58 call rank1_flb(c1)
59
60 ! kind=1, deferred length
61 call rank1_dl (null(d1))
62 call rank1_dl (null())
63 call rank1_dl (d1)
64 call arank_dl (null(d1))
65 call arank_dl (d1)
66 call rank1_dlb(null(d1))
67 call rank1_dlb(null())
68
69 ! kind=4, assumed length
70 call rank1_al_4 (null(c4))
71 call rank1_al_4 (c4)
72 call arank_al_4 (null(c4))
73 call arank_al_4 (c4)
74 call rank1_al_4b(null(c4))
75 call rank1_al_4b(c4)
76
77 ! kind=4, fixed length
78 call rank1_fl_4 (null(c4))
79 call rank1_fl_4 (null())
80 call rank1_fl_4 (c4)
81 call arank_fl_4 (null(c4))
82 call arank_fl_4 (c4)
83 call rank1_fl_4b(null(c4))
84 call rank1_fl_4b(c4)
85
86 ! kind=4, deferred length
87 call rank1_dl_4 (null(d4))
88 call rank1_dl_4 (null())
89 call rank1_dl_4 (d4)
90 call arank_dl_4 (null(d4))
91 call arank_dl_4 (d4)
92 call rank1_dl_4b(null(d4))
93 call rank1_dl_4b(null())
94
95 contains
96
97 ! kind=4, rank=1
98 subroutine rank1_al_4 (x)
99 character(kind=4,len=*), pointer, intent(in) :: x(:)
100 if (associated (x)) stop 41
101 end
102 subroutine rank1_fl_4 (x)
103 character(kind=4,len=10), pointer, intent(in) :: x(:)
104 if (associated (x)) stop 42
105 end
106 subroutine rank1_dl_4 (x)
107 character(kind=4,len=:), pointer, intent(in) :: x(:)
108 if (associated (x)) stop 43
109 end
110
111 subroutine rank1_al_4b (y)
112 character(kind=4,len=*), pointer, intent(in) :: y(:)
113 call rank1_al_4 (y)
114 if (associated (y)) stop 44
115 end
116 subroutine rank1_fl_4b (y)
117 character(kind=4,len=10), pointer, intent(in) :: y(:)
118 call rank1_fl_4 (y)
119 if (associated (y)) stop 45
120 end
121 subroutine rank1_dl_4b (y)
122 character(kind=4,len=:), pointer, intent(in) :: y(:)
123 call rank1_dl_4 (y)
124 if (associated (y)) stop 46
125 end
126
127 ! kind=4, assumed-rank versions
128 subroutine arank_al_4 (x)
129 character(kind=4,len=*), pointer, intent(in) :: x(..)
130 if (associated (x)) stop 47
131 ! this testcase assumes that we call this subroutine only with rank=1
132 if (rank (x) /= 1) stop 57
133 end
134 subroutine arank_fl_4 (x)
135 character(kind=4,len=10), pointer, intent(in) :: x(..)
136 if (associated (x)) stop 48
137 ! this testcase assumes that we call this subroutine only with rank=1
138 if (rank (x) /= 1) stop 58
139 end
140 subroutine arank_dl_4 (x)
141 character(kind=4,len=:), pointer, intent(in) :: x(..)
142 if (associated (x)) stop 49
143 ! this testcase assumes that we call this subroutine only with rank=1
144 if (rank (x) /= 1) stop 59
145 end
146
147 ! kind=1, rank=1
148 subroutine rank1_al (x)
149 character(kind=1,len=*), pointer, intent(in) :: x(:)
150 if (associated (x)) stop 11
151 end
152 subroutine rank1_fl (x)
153 character(kind=1,len=10), pointer, intent(in) :: x(:)
154 if (associated (x)) stop 12
155 end
156 subroutine rank1_dl (x)
157 character(kind=1,len=:), pointer, intent(in) :: x(:)
158 if (associated (x)) stop 13
159 end
160
161 subroutine rank1_alb (y)
162 character(kind=1,len=*), pointer, intent(in) :: y(:)
163 call rank1_al (y)
164 if (associated (y)) stop 14
165 end
166 subroutine rank1_flb (y)
167 character(kind=1,len=10), pointer, intent(in) :: y(:)
168 call rank1_fl (y)
169 if (associated (y)) stop 15
170 end
171 subroutine rank1_dlb (y)
172 character(kind=1,len=:), pointer, intent(in) :: y(:)
173 call rank1_dl (y)
174 if (associated (y)) stop 16
175 end
176
177 ! kind=1, assumed-rank versions
178 subroutine arank_al (x)
179 character(kind=1,len=*), pointer, intent(in) :: x(..)
180 if (associated (x)) stop 17
181 end
182 subroutine arank_fl (x)
183 character(kind=1,len=10), pointer, intent(in) :: x(..)
184 if (associated (x)) stop 18
185 end
186 subroutine arank_dl (x)
187 character(kind=1,len=:), pointer, intent(in) :: x(..)
188 if (associated (x)) stop 19
189 end
190
191 ! kind=1, scalar
192 subroutine rank0_al (x)
193 character(kind=1,len=*), pointer, intent(in) :: x
194 if (associated (x)) stop 1
195 end
196 subroutine rank0_fl (x)
197 character(kind=1,len=10), pointer, intent(in) :: x
198 if (associated (x)) stop 2
199 end
200 subroutine rank0_dl (x)
201 character(kind=1,len=:), pointer, intent(in) :: x
202 if (associated (x)) stop 3
203 end
204
205 subroutine rank0_alb (y)
206 character(kind=1,len=*), pointer, intent(in) :: y
207 call rank0_al (y)
208 if (associated (y)) stop 4
209 end
210 subroutine rank0_flb (y)
211 character(kind=1,len=10), pointer, intent(in) :: y
212 call rank0_fl (y)
213 if (associated (y)) stop 5
214 end
215 subroutine rank0_dlb (y)
216 character(kind=1,len=:), pointer, intent(in) :: y
217 call rank0_dl (y)
218 if (associated (y)) stop 6
219 end
220
221 end