File: modfile07.f90

package info (click to toggle)
swiftlang 6.0.3-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,519,992 kB
  • sloc: cpp: 9,107,863; ansic: 2,040,022; asm: 1,135,751; python: 296,500; objc: 82,456; f90: 60,502; lisp: 34,951; pascal: 19,946; sh: 18,133; perl: 7,482; ml: 4,937; javascript: 4,117; makefile: 3,840; awk: 3,535; xml: 914; fortran: 619; cs: 573; ruby: 573
file content (626 lines) | stat: -rw-r--r-- 9,913 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
! RUN: %python %S/test_modfile.py %s %flang_fc1
! Check modfile generation for generic interfaces
module m1
  interface foo
    real function s1(x,y)
      real, intent(in) :: x
      logical, intent(in) :: y
    end function
    complex function s2(x,y)
      complex, intent(in) :: x
      logical, intent(in) :: y
    end function
  end interface
  generic :: operator ( + ) => s1, s2
  interface operator ( /= )
    logical function f1(x, y)
      real, intent(in) :: x
      logical, intent(in) :: y
    end function
  end interface
  interface
    logical function f2(x, y)
      complex, intent(in) :: x
      logical, intent(in) :: y
    end function
    logical function f3(x, y)
      integer, intent(in) :: x
      logical, intent(in) :: y
    end function
  end interface
  generic :: operator(.ne.) => f2
  generic :: operator(<>) => f3
  private :: operator( .ne. )
  interface bar
    procedure :: s1
    procedure :: s2
    procedure :: s3
    procedure :: s4
  end interface
  interface operator( .bar.)
    procedure :: s1
    procedure :: s2
    procedure :: s3
    procedure :: s4
  end interface
contains
  logical function s3(x,y)
    logical, intent(in) :: x,y
  end function
  integer function s4(x,y)
    integer, intent(in) :: x,y
  end function
end
!Expect: m1.mod
!module m1
! interface foo
!  procedure::s1
!  procedure::s2
! end interface
! interface
!  function s1(x,y)
!   real(4),intent(in)::x
!   logical(4),intent(in)::y
!   real(4)::s1
!  end
! end interface
! interface
!  function s2(x,y)
!   complex(4),intent(in)::x
!   logical(4),intent(in)::y
!   complex(4)::s2
!  end
! end interface
! interface operator(+)
!  procedure::s1
!  procedure::s2
! end interface
! interface operator(/=)
!  procedure::f1
!  procedure::f2
!  procedure::f3
! end interface
! private::operator(/=)
! interface
!  function f1(x,y)
!   real(4),intent(in)::x
!   logical(4),intent(in)::y
!   logical(4)::f1
!  end
! end interface
! interface
!  function f2(x,y)
!   complex(4),intent(in)::x
!   logical(4),intent(in)::y
!   logical(4)::f2
!  end
! end interface
! interface
!  function f3(x,y)
!   integer(4),intent(in)::x
!   logical(4),intent(in)::y
!   logical(4)::f3
!  end
! end interface
! interface bar
!  procedure::s1
!  procedure::s2
!  procedure::s3
!  procedure::s4
! end interface
! interface operator(.bar.)
!  procedure::s1
!  procedure::s2
!  procedure::s3
!  procedure::s4
! end interface
!contains
! function s3(x,y)
!  logical(4),intent(in)::x
!  logical(4),intent(in)::y
!  logical(4)::s3
! end
! function s4(x,y)
!  integer(4),intent(in)::x
!  integer(4),intent(in)::y
!  integer(4)::s4
! end
!end

module m1b
  use m1
end
!Expect: m1b.mod
!module m1b
! use m1,only:foo
! use m1,only:s1
! use m1,only:s2
! use m1,only:operator(+)
! use m1,only:f1
! use m1,only:f2
! use m1,only:f3
! use m1,only:bar
! use m1,only:operator(.bar.)
! use m1,only:s3
! use m1,only:s4
!end

module m1c
  use m1, only: myfoo => foo
  use m1, only: operator(.bar.)
  use m1, only: operator(.mybar.) => operator(.bar.)
  use m1, only: operator(+)
end
!Expect: m1c.mod
!module m1c
! use m1,only:myfoo=>foo
! use m1,only:operator(.bar.)
! use m1,only:operator(.mybar.)=>operator(.bar.)
! use m1,only:operator(+)
!end

module m2
  interface foo
    procedure foo
  end interface
contains
  complex function foo()
    foo = 1.0
  end
end
!Expect: m2.mod
!module m2
! interface foo
!  procedure::foo
! end interface
!contains
! function foo()
!  complex(4)::foo
! end
!end

module m2b
  type :: foo
    real :: x
  end type
  interface foo
  end interface
  private :: bar
  interface bar
  end interface
end
!Expect: m2b.mod
!module m2b
! interface foo
! end interface
! type::foo
!  real(4)::x
! end type
! interface bar
! end interface
! private::bar
!end

! Test interface nested inside another interface
module m3
  interface g
    subroutine s1(f)
      interface
        real function f(x)
          interface
            subroutine x()
            end subroutine
          end interface
        end function
      end interface
    end subroutine
  end interface
end
!Expect: m3.mod
!module m3
! interface g
!  procedure::s1
! end interface
! interface
!  subroutine s1(f)
!   interface
!    function f(x)
!     interface
!      subroutine x()
!      end
!     end interface
!     real(4)::f
!    end
!   end interface
!  end
! end interface
!end

module m4
  interface foo
    integer function foo()
    end function
    integer function f(x)
    end function
  end interface
end
subroutine s4
  use m4
  i = foo()
end
!Expect: m4.mod
!module m4
! interface foo
!  procedure::foo
!  procedure::f
! end interface
! interface
!  function foo()
!   integer(4)::foo
!  end
! end interface
! interface
!  function f(x)
!   real(4)::x
!   integer(4)::f
!  end
! end interface
!end

! Compile contents of m4.mod and verify it gets the same thing again.
module m5
 interface foo
  procedure::foo
  procedure::f
 end interface
 interface
  function foo()
   integer(4)::foo
  end
 end interface
 interface
  function f(x)
   integer(4)::f
   real(4)::x
  end
 end interface
end
!Expect: m5.mod
!module m5
! interface foo
!  procedure::foo
!  procedure::f
! end interface
! interface
!  function foo()
!   integer(4)::foo
!  end
! end interface
! interface
!  function f(x)
!   real(4)::x
!   integer(4)::f
!  end
! end interface
!end

module m6a
  interface operator(<)
    logical function lt(x, y)
      logical, intent(in) :: x, y
    end function
  end interface
end
!Expect: m6a.mod
!module m6a
! interface operator(<)
!  procedure::lt
! end interface
! interface
!  function lt(x,y)
!   logical(4),intent(in)::x
!   logical(4),intent(in)::y
!   logical(4)::lt
!  end
! end interface
!end

module m6b
  use m6a, only: operator(.lt.)
end
!Expect: m6b.mod
!module m6b
! use m6a,only:operator(.lt.)
!end

module m7a
  interface g_integer
    module procedure s
  end interface
  private :: s
contains
  subroutine s(x)
    integer :: x
  end
end
!Expect: m7a.mod
!module m7a
! interface g_integer
!  procedure :: s
! end interface
! private :: s
!contains
! subroutine s(x)
!  integer(4) :: x
! end
!end

module m7b
  interface g_real
    module procedure s
  end interface
  private :: s
contains
  subroutine s(x)
    real :: x
  end subroutine
end
!Expect: m7b.mod
!module m7b
! interface g_real
!  procedure :: s
! end interface
! private :: s
!contains
! subroutine s(x)
!  real(4) :: x
! end
!end

module m7c
  use m7a, only: g => g_integer
  use m7b, only: g => g_real
  interface g
    module procedure s
  end interface
  private :: s
contains
  subroutine s(x)
    complex :: x
  end subroutine
  subroutine test()
    real :: x
    integer :: y
    complex :: z
    call g(x)
    call g(y)
    call g(z)
  end
end
!Expect: m7c.mod
!module m7c
! use m7a, only: g => g_integer
! use m7b, only: g => g_real
! interface g
!  procedure :: s
! end interface
! private :: s
!contains
! subroutine s(x)
!  complex(4) :: x
! end
! subroutine test()
! end
!end

! Test m8 is like m7 but without renaming.

module m8a
  interface g
    module procedure s
  end interface
  private :: s
contains
  subroutine s(x)
    integer :: x
  end
end
!Expect: m8a.mod
!module m8a
! interface g
!  procedure :: s
! end interface
! private :: s
!contains
! subroutine s(x)
!  integer(4) :: x
! end
!end

module m8b
  interface g
    module procedure s
  end interface
  private :: s
contains
  subroutine s(x)
    real :: x
  end subroutine
end
!Expect: m8b.mod
!module m8b
! interface g
!  procedure :: s
! end interface
! private :: s
!contains
! subroutine s(x)
!  real(4) :: x
! end
!end

module m8c
  use m8a
  use m8b
  interface g
    module procedure s
  end interface
  private :: s
contains
  subroutine s(x)
    complex :: x
  end subroutine
  subroutine test()
    real :: x
    integer :: y
    complex :: z
    call g(x)
    call g(y)
    call g(z)
  end
end
!Expect: m8c.mod
!module m8c
! use m8a, only: g
! use m8b, only: g
! interface g
!  procedure :: s
! end interface
! private :: s
!contains
! subroutine s(x)
!  complex(4) :: x
! end
! subroutine test()
! end
!end

! Merging a use-associated generic with a local generic

module m9a
  interface g
    module procedure s
  end interface
  private :: s
contains
  subroutine s(x)
    integer :: x
  end
end
!Expect: m9a.mod
!module m9a
! interface g
!  procedure :: s
! end interface
! private :: s
!contains
! subroutine s(x)
!  integer(4) :: x
! end
!end

module m9b
  use m9a
  interface g
    module procedure s
  end interface
  private :: s
contains
  subroutine s(x)
    real :: x
  end
  subroutine test()
    call g(1)
    call g(1.0)
  end
end
!Expect: m9b.mod
!module m9b
! use m9a,only:g
! interface g
!   procedure::s
! end interface
! private::s
!contains
! subroutine s(x)
!   real(4)::x
! end
! subroutine test()
! end
!end

! Verify that equivalent names are used when generic operators are merged

module m10a
  interface operator(.ne.)
  end interface
end
!Expect: m10a.mod
!module m10a
! interface operator(.ne.)
! end interface
!end

module m10b
  interface operator(<>)
  end interface
end
!Expect: m10b.mod
!module m10b
! interface operator(<>)
! end interface
!end

module m10c
  use m10a
  use m10b
  interface operator(/=)
  end interface
end
!Expect: m10c.mod
!module m10c
! use m10a,only:operator(.ne.)
! use m10b,only:operator(.ne.)
! interface operator(.ne.)
! end interface
!end

module m10d
  use m10a
  use m10c
  private :: operator(<>)
end
!Expect: m10d.mod
!module m10d
! use m10a,only:operator(.ne.)
! use m10c,only:operator(.ne.)
! interface operator(.ne.)
! end interface
! private::operator(.ne.)
!end

module m11a
contains
  subroutine s1()
  end
end
!Expect: m11a.mod
!module m11a
!contains
! subroutine s1()
! end
!end

module m11b
  use m11a
  interface g
    module procedure s1
  end interface
end
!Expect: m11b.mod
!module m11b
! use m11a,only:s1
! interface g
!  procedure::s1
! end interface
!end