1! RUN: %S/test_modfile.sh %s %f18 %t
2! Check modfile generation for generic interfaces
3module m1
4  interface foo
5    real function s1(x,y)
6      real, intent(in) :: x
7      logical, intent(in) :: y
8    end function
9    complex function s2(x,y)
10      complex, intent(in) :: x
11      logical, intent(in) :: y
12    end function
13  end interface
14  generic :: operator ( + ) => s1, s2
15  interface operator ( /= )
16    logical function f1(x, y)
17      real, intent(in) :: x
18      logical, intent(in) :: y
19    end function
20  end interface
21  interface
22    logical function f2(x, y)
23      complex, intent(in) :: x
24      logical, intent(in) :: y
25    end function
26    logical function f3(x, y)
27      integer, intent(in) :: x
28      logical, intent(in) :: y
29    end function
30  end interface
31  generic :: operator(.ne.) => f2
32  generic :: operator(<>) => f3
33  private :: operator( .ne. )
34  interface bar
35    procedure :: s1
36    procedure :: s2
37    procedure :: s3
38    procedure :: s4
39  end interface
40  interface operator( .bar.)
41    procedure :: s1
42    procedure :: s2
43    procedure :: s3
44    procedure :: s4
45  end interface
46contains
47  logical function s3(x,y)
48    logical, intent(in) :: x,y
49  end function
50  integer function s4(x,y)
51    integer, intent(in) :: x,y
52  end function
53end
54!Expect: m1.mod
55!module m1
56! interface foo
57!  procedure::s1
58!  procedure::s2
59! end interface
60! interface
61!  function s1(x,y)
62!   real(4),intent(in)::x
63!   logical(4),intent(in)::y
64!   real(4)::s1
65!  end
66! end interface
67! interface
68!  function s2(x,y)
69!   complex(4),intent(in)::x
70!   logical(4),intent(in)::y
71!   complex(4)::s2
72!  end
73! end interface
74! interface operator(+)
75!  procedure::s1
76!  procedure::s2
77! end interface
78! interface operator(/=)
79!  procedure::f1
80!  procedure::f2
81!  procedure::f3
82! end interface
83! private::operator(/=)
84! interface
85!  function f1(x,y)
86!   real(4),intent(in)::x
87!   logical(4),intent(in)::y
88!   logical(4)::f1
89!  end
90! end interface
91! interface
92!  function f2(x,y)
93!   complex(4),intent(in)::x
94!   logical(4),intent(in)::y
95!   logical(4)::f2
96!  end
97! end interface
98! interface
99!  function f3(x,y)
100!   integer(4),intent(in)::x
101!   logical(4),intent(in)::y
102!   logical(4)::f3
103!  end
104! end interface
105! interface bar
106!  procedure::s1
107!  procedure::s2
108!  procedure::s3
109!  procedure::s4
110! end interface
111! interface operator(.bar.)
112!  procedure::s1
113!  procedure::s2
114!  procedure::s3
115!  procedure::s4
116! end interface
117!contains
118! function s3(x,y)
119!  logical(4),intent(in)::x
120!  logical(4),intent(in)::y
121!  logical(4)::s3
122! end
123! function s4(x,y)
124!  integer(4),intent(in)::x
125!  integer(4),intent(in)::y
126!  integer(4)::s4
127! end
128!end
129
130module m1b
131  use m1
132end
133!Expect: m1b.mod
134!module m1b
135! use m1,only:foo
136! use m1,only:s1
137! use m1,only:s2
138! use m1,only:operator(+)
139! use m1,only:f1
140! use m1,only:f2
141! use m1,only:f3
142! use m1,only:bar
143! use m1,only:operator(.bar.)
144! use m1,only:s3
145! use m1,only:s4
146!end
147
148module m1c
149  use m1, only: myfoo => foo
150  use m1, only: operator(.bar.)
151  use m1, only: operator(.mybar.) => operator(.bar.)
152  use m1, only: operator(+)
153end
154!Expect: m1c.mod
155!module m1c
156! use m1,only:myfoo=>foo
157! use m1,only:operator(.bar.)
158! use m1,only:operator(.mybar.)=>operator(.bar.)
159! use m1,only:operator(+)
160!end
161
162module m2
163  interface foo
164    procedure foo
165  end interface
166contains
167  complex function foo()
168    foo = 1.0
169  end
170end
171!Expect: m2.mod
172!module m2
173! interface foo
174!  procedure::foo
175! end interface
176!contains
177! function foo()
178!  complex(4)::foo
179! end
180!end
181
182module m2b
183  type :: foo
184    real :: x
185  end type
186  interface foo
187  end interface
188  private :: bar
189  interface bar
190  end interface
191end
192!Expect: m2b.mod
193!module m2b
194! interface foo
195! end interface
196! type::foo
197!  real(4)::x
198! end type
199! interface bar
200! end interface
201! private::bar
202!end
203
204! Test interface nested inside another interface
205module m3
206  interface g
207    subroutine s1(f)
208      interface
209        real function f(x)
210          interface
211            subroutine x()
212            end subroutine
213          end interface
214        end function
215      end interface
216    end subroutine
217  end interface
218end
219!Expect: m3.mod
220!module m3
221! interface g
222!  procedure::s1
223! end interface
224! interface
225!  subroutine s1(f)
226!   interface
227!    function f(x)
228!     interface
229!      subroutine x()
230!      end
231!     end interface
232!     real(4)::f
233!    end
234!   end interface
235!  end
236! end interface
237!end
238
239module m4
240  interface foo
241    integer function foo()
242    end function
243    integer function f(x)
244    end function
245  end interface
246end
247subroutine s4
248  use m4
249  i = foo()
250end
251!Expect: m4.mod
252!module m4
253! interface foo
254!  procedure::foo
255!  procedure::f
256! end interface
257! interface
258!  function foo()
259!   integer(4)::foo
260!  end
261! end interface
262! interface
263!  function f(x)
264!   real(4)::x
265!   integer(4)::f
266!  end
267! end interface
268!end
269
270! Compile contents of m4.mod and verify it gets the same thing again.
271module m5
272 interface foo
273  procedure::foo
274  procedure::f
275 end interface
276 interface
277  function foo()
278   integer(4)::foo
279  end
280 end interface
281 interface
282  function f(x)
283   integer(4)::f
284   real(4)::x
285  end
286 end interface
287end
288!Expect: m5.mod
289!module m5
290! interface foo
291!  procedure::foo
292!  procedure::f
293! end interface
294! interface
295!  function foo()
296!   integer(4)::foo
297!  end
298! end interface
299! interface
300!  function f(x)
301!   real(4)::x
302!   integer(4)::f
303!  end
304! end interface
305!end
306
307module m6a
308  interface operator(<)
309    logical function lt(x, y)
310      logical, intent(in) :: x, y
311    end function
312  end interface
313end
314!Expect: m6a.mod
315!module m6a
316! interface operator(<)
317!  procedure::lt
318! end interface
319! interface
320!  function lt(x,y)
321!   logical(4),intent(in)::x
322!   logical(4),intent(in)::y
323!   logical(4)::lt
324!  end
325! end interface
326!end
327
328module m6b
329  use m6a, only: operator(.lt.)
330end
331!Expect: m6b.mod
332!module m6b
333! use m6a,only:operator(.lt.)
334!end
335