File: modfile71.F90

package info (click to toggle)
llvm-toolchain-20 1%3A20.1.8-1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 2,111,696 kB
  • sloc: cpp: 7,438,781; ansic: 1,393,871; asm: 1,012,926; python: 241,771; f90: 86,635; objc: 75,411; lisp: 42,144; pascal: 17,286; sh: 8,596; ml: 5,082; perl: 4,730; makefile: 3,591; awk: 3,523; javascript: 2,251; xml: 892; fortran: 672
file content (121 lines) | stat: -rw-r--r-- 4,444 bytes parent folder | download | duplicates (2)
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
!RUN: %flang_fc1 -fsyntax-only -fhermetic-module-files -DSTEP=1 %s
!RUN: %flang_fc1 -fsyntax-only -DSTEP=2 %s
!RUN: not %flang_fc1 -fsyntax-only -pedantic %s 2>&1 | FileCheck %s

! Tests that a module captured in a hermetic module file is compatible when
! USE'd with a module of the same name USE'd directly.

#if STEP == 1
module modfile71a
  ! not errors
  integer, parameter :: good_named_const = 123
  integer :: good_var = 1
  type :: good_derived
    integer component
  end type
  procedure(), pointer :: good_proc_ptr
  generic :: gen => bad_subroutine
  ! bad, but okay if unused
  integer, parameter :: unused_bad_named_const = 123
  integer :: unused_bad_var = 1
  type :: unused_bad_derived
    integer component
  end type
  procedure(), pointer :: unused_bad_proc_ptr
  ! errors
  integer, parameter :: bad_named_const = 123
  integer :: bad_var = 1
  type :: bad_derived
    integer component
  end type
  procedure(), pointer :: bad_proc_ptr
 contains
  subroutine good_subroutine
  end
  subroutine unused_bad_subroutine(x)
    integer x
  end
  subroutine bad_subroutine(x)
    integer x
  end
end

module modfile71b
  use modfile71a ! capture hermetically
end

#elif STEP == 2
module modfile71a
  ! not errors
  integer, parameter :: good_named_const = 123
  integer :: good_var = 1
  type :: good_derived
    integer component
  end type
  procedure(), pointer :: good_proc_ptr
  generic :: gen => bad_subroutine
  ! bad, but okay if unused
  integer, parameter :: unused_bad_named_const = 666
  real :: unused_bad_var = 1.
  type :: unused_bad_derived
    real component
  end type
  real, pointer :: unused_bad_proc_ptr
  ! errors
  integer, parameter :: bad_named_const = 666
  real :: bad_var = 1.
  type :: bad_derived
    real component
  end type
  real, pointer :: bad_proc_ptr
 contains
  subroutine good_subroutine
  end
  subroutine unused_bad_subroutine(x)
    real x
  end
  subroutine bad_subroutine(x)
    real x
  end
end

#else

!CHECK: warning: 'bad_derived' is use-associated from 'bad_derived' in two distinct instances of module 'modfile71a'
!CHECK: warning: 'bad_named_const' is use-associated from 'bad_named_const' in two distinct instances of module 'modfile71a'
!CHECK: warning: 'bad_proc_ptr' is use-associated from 'bad_proc_ptr' in two distinct instances of module 'modfile71a'
!CHECK: warning: 'bad_subroutine' is use-associated from 'bad_subroutine' in two distinct instances of module 'modfile71a'
!CHECK: warning: 'bad_var' is use-associated from 'bad_var' in two distinct instances of module 'modfile71a'
!CHECK: warning: 'good_derived' is use-associated from 'good_derived' in two distinct instances of module 'modfile71a'
!CHECK: warning: 'good_named_const' is use-associated from 'good_named_const' in two distinct instances of module 'modfile71a'
!CHECK: warning: 'good_proc_ptr' is use-associated from 'good_proc_ptr' in two distinct instances of module 'modfile71a'
!CHECK: warning: 'good_subroutine' is use-associated from 'good_subroutine' in two distinct instances of module 'modfile71a'
!CHECK: warning: 'good_var' is use-associated from 'good_var' in two distinct instances of module 'modfile71a'
!CHECK: warning: 'unused_bad_derived' is use-associated from 'unused_bad_derived' in two distinct instances of module 'modfile71a'
!CHECK: warning: 'unused_bad_named_const' is use-associated from 'unused_bad_named_const' in two distinct instances of module 'modfile71a'
!CHECK: warning: 'unused_bad_proc_ptr' is use-associated from 'unused_bad_proc_ptr' in two distinct instances of module 'modfile71a'
!CHECK: warning: 'unused_bad_subroutine' is use-associated from 'unused_bad_subroutine' in two distinct instances of module 'modfile71a'
!CHECK: warning: 'unused_bad_var' is use-associated from 'unused_bad_var' in two distinct instances of module 'modfile71a'
!CHECK: error: Reference to 'bad_derived' is ambiguous
!CHECK: error: Reference to 'bad_named_const' is ambiguous
!CHECK: error: Reference to 'bad_var' is ambiguous
!CHECK: error: Reference to 'bad_proc_ptr' is ambiguous
!CHECK: error: Reference to 'bad_subroutine' is ambiguous
!CHECK-NOT: error:
!CHECK-NOT: warning:

program main
  use modfile71a
  use modfile71b
  type(good_derived) goodx
  type(bad_derived) badx
  print *, good_named_const
  good_var = 1
  good_proc_ptr => null()
  call good_subroutine
  print *, bad_named_const
  print *, bad_var
  bad_proc_ptr => null()
  call bad_subroutine(1)
end
#endif