1! RUN: %python %S/test_symbols.py %s %flang_fc1
2! Tests for "proc-interface" semantics.
3! These cases are all valid.
4
5!DEF: /module1 Module
6module module1
7 abstract interface
8  !DEF: /module1/abstract1 ABSTRACT, PUBLIC (Function) Subprogram REAL(4)
9  !DEF: /module1/abstract1/x INTENT(IN) ObjectEntity REAL(4)
10  real function abstract1(x)
11   !REF: /module1/abstract1/x
12   real, intent(in) :: x
13  end function abstract1
14 end interface
15
16 interface
17  !DEF: /module1/explicit1 EXTERNAL, PUBLIC (Function) Subprogram REAL(4)
18  !DEF: /module1/explicit1/x INTENT(IN) ObjectEntity REAL(4)
19  real function explicit1(x)
20   !REF: /module1/explicit1/x
21   real, intent(in) :: x
22  end function explicit1
23  !DEF: /module1/logical EXTERNAL, PUBLIC (Function) Subprogram INTEGER(4)
24  !DEF: /module1/logical/x INTENT(IN) ObjectEntity REAL(4)
25  integer function logical(x)
26   !REF: /module1/logical/x
27   real, intent(in) :: x
28  end function logical
29  !DEF: /module1/tan EXTERNAL, PUBLIC (Function) Subprogram CHARACTER(1_4,1)
30  !DEF: /module1/tan/x INTENT(IN) ObjectEntity REAL(4)
31  character(len=1) function tan(x)
32   !REF: /module1/tan/x
33   real, intent(in) :: x
34  end function tan
35 end interface
36
37 !DEF: /module1/derived1 PUBLIC DerivedType
38 type :: derived1
39  !REF: /module1/abstract1
40  !DEF: /module1/derived1/p1 NOPASS, POINTER (Function) ProcEntity REAL(4)
41  !DEF: /module1/nested1 PUBLIC (Function) Subprogram REAL(4)
42  procedure(abstract1), pointer, nopass :: p1 => nested1
43  !REF: /module1/explicit1
44  !DEF: /module1/derived1/p2 NOPASS, POINTER (Function) ProcEntity REAL(4)
45  !REF: /module1/nested1
46  procedure(explicit1), pointer, nopass :: p2 => nested1
47  !DEF: /module1/derived1/p3 NOPASS, POINTER (Function) ProcEntity LOGICAL(4)
48  !DEF: /module1/nested2 PUBLIC (Function) Subprogram LOGICAL(4)
49  procedure(logical), pointer, nopass :: p3 => nested2
50  !DEF: /module1/derived1/p4 NOPASS, POINTER (Function) ProcEntity LOGICAL(4)
51  !DEF: /module1/nested3 PUBLIC (Function) Subprogram LOGICAL(4)
52  procedure(logical(kind=4)), pointer, nopass :: p4 => nested3
53  !DEF: /module1/derived1/p5 NOPASS, POINTER (Function) ProcEntity COMPLEX(4)
54  !DEF: /module1/nested4 PUBLIC (Function) Subprogram COMPLEX(4)
55  procedure(complex), pointer, nopass :: p5 => nested4
56  !DEF: /module1/sin ELEMENTAL, INTRINSIC, PUBLIC, PURE (Function) ProcEntity
57  !DEF: /module1/derived1/p6 NOPASS, POINTER (Function) ProcEntity
58  !REF: /module1/nested1
59  procedure(sin), pointer, nopass :: p6 => nested1
60  !REF: /module1/sin
61  !DEF: /module1/derived1/p7 NOPASS, POINTER (Function) ProcEntity
62  !DEF: /module1/cos ELEMENTAL, INTRINSIC, PUBLIC, PURE (Function) ProcEntity
63  procedure(sin), pointer, nopass :: p7 => cos
64  !REF: /module1/tan
65  !DEF: /module1/derived1/p8 NOPASS, POINTER (Function) ProcEntity CHARACTER(1_4,1)
66  !DEF: /module1/nested5 PUBLIC (Function) Subprogram CHARACTER(1_8,1)
67  procedure(tan), pointer, nopass :: p8 => nested5
68 end type derived1
69
70contains
71
72 !REF: /module1/nested1
73 !DEF: /module1/nested1/x INTENT(IN) ObjectEntity REAL(4)
74 real function nested1(x)
75  !REF: /module1/nested1/x
76  real, intent(in) :: x
77  !DEF: /module1/nested1/nested1 ObjectEntity REAL(4)
78  !REF: /module1/nested1/x
79  nested1 = x+1.
80 end function nested1
81
82 !REF: /module1/nested2
83 !DEF: /module1/nested2/x INTENT(IN) ObjectEntity REAL(4)
84 logical function nested2(x)
85  !REF: /module1/nested2/x
86  real, intent(in) :: x
87  !DEF: /module1/nested2/nested2 ObjectEntity LOGICAL(4)
88  !REF: /module1/nested2/x
89  nested2 = x/=0
90 end function nested2
91
92 !REF: /module1/nested3
93 !DEF: /module1/nested3/x INTENT(IN) ObjectEntity REAL(4)
94 logical function nested3(x)
95  !REF: /module1/nested3/x
96  real, intent(in) :: x
97  !DEF: /module1/nested3/nested3 ObjectEntity LOGICAL(4)
98  !REF: /module1/nested3/x
99  nested3 = x>0
100 end function nested3
101
102 !REF: /module1/nested4
103 !DEF: /module1/nested4/x INTENT(IN) ObjectEntity REAL(4)
104 complex function nested4(x)
105  !REF: /module1/nested4/x
106  real, intent(in) :: x
107  !DEF: /module1/nested4/nested4 ObjectEntity COMPLEX(4)
108  !DEF: /module1/nested4/cmplx ELEMENTAL, INTRINSIC, PURE (Function) ProcEntity
109  !REF: /module1/nested4/x
110  nested4 = cmplx(x+4., 6.)
111 end function nested4
112
113 !REF: /module1/nested5
114 !DEF: /module1/nested5/x INTENT(IN) ObjectEntity REAL(4)
115 character function nested5(x)
116  !REF: /module1/nested5/x
117  real, intent(in) :: x
118  !DEF: /module1/nested5/nested5 ObjectEntity CHARACTER(1_8,1)
119  nested5 = "a"
120 end function nested5
121end module module1
122
123!DEF: /explicit1 ELEMENTAL (Function) Subprogram REAL(4)
124!DEF: /explicit1/x INTENT(IN) ObjectEntity REAL(4)
125real elemental function explicit1(x)
126 !REF: /explicit1/x
127 real, intent(in) :: x
128 !DEF: /explicit1/explicit1 ObjectEntity REAL(4)
129 !REF: /explicit1/x
130 explicit1 = -x
131end function explicit1
132
133!DEF: /logical (Function) Subprogram INTEGER(4)
134!DEF: /logical/x INTENT(IN) ObjectEntity REAL(4)
135integer function logical(x)
136 !REF: /logical/x
137 real, intent(in) :: x
138 !DEF: /logical/logical ObjectEntity INTEGER(4)
139 !REF: /logical/x
140 logical = x+3.
141end function logical
142
143!DEF: /tan (Function) Subprogram REAL(4)
144!DEF: /tan/x INTENT(IN) ObjectEntity REAL(4)
145real function tan(x)
146 !REF: /tan/x
147 real, intent(in) :: x
148 !DEF: /tan/tan ObjectEntity REAL(4)
149 !REF: /tan/x
150 tan = x+5.
151end function tan
152
153!DEF: /main MainProgram
154program main
155 !REF: /module1
156 use :: module1
157 !DEF: /main/derived1 Use
158 !DEF: /main/instance ObjectEntity TYPE(derived1)
159 type(derived1) :: instance
160 !REF: /main/instance
161 !REF: /module1/derived1/p1
162 if (instance%p1(1.)/=2.) print *, "p1 failed"
163 !REF: /main/instance
164 !REF: /module1/derived1/p2
165 if (instance%p2(1.)/=2.) print *, "p2 failed"
166 !REF: /main/instance
167 !REF: /module1/derived1/p3
168 if (.not.instance%p3(1.)) print *, "p3 failed"
169 !REF: /main/instance
170 !REF: /module1/derived1/p4
171 if (.not.instance%p4(1.)) print *, "p4 failed"
172 !REF: /main/instance
173 !REF: /module1/derived1/p5
174 if (instance%p5(1.)/=(5.,6.)) print *, "p5 failed"
175 !REF: /main/instance
176 !REF: /module1/derived1/p6
177 if (instance%p6(1.)/=2.) print *, "p6 failed"
178 !REF: /main/instance
179 !REF: /module1/derived1/p7
180 if (instance%p7(0.)/=1.) print *, "p7 failed"
181 !REF: /main/instance
182 !REF: /module1/derived1/p8
183 if (instance%p8(1.)/="a") print *, "p8 failed"
184end program main
185