1 ! RUN: %python %S/test_errors.py %s %flang_fc1
2 ! Test 15.5.2.9(2,3,5) dummy procedure requirements
4 ! An entity with the INTENT attribute shall be a dummy data object or a
5 ! dummy procedure pointer.
10 integer function intfunc(x
)
11 integer, intent(in
) :: x
14 real function realfunc(x
)
20 procedure(realfunc
), pointer, intent(in
) :: p
23 procedure(realfunc
), pointer :: p
26 procedure(real), pointer :: p
29 procedure(realfunc
) :: p
32 !ERROR: A dummy procedure without the POINTER attribute may not have an INTENT attribute
33 procedure(realfunc
), intent(in
) :: p
36 procedure(realfunc
), pointer, intent(in out
) :: p
39 subroutine selemental1(p
)
40 procedure(cos
) :: p
! ok
43 real elemental
function elemfunc(x
)
47 subroutine selemental2(p
)
48 !ERROR: A dummy procedure may not be ELEMENTAL
49 procedure(elemfunc
) :: p
53 procedure(realfunc
), pointer :: procptr
57 procedure(intfunc
), pointer :: intprocptr
61 subroutine test1
! 15.5.2.9(5)
63 procedure(realfunc
), pointer :: p
64 procedure(intfunc
), pointer :: ip
65 integer, pointer :: intPtr
68 call s01(realfunc
) ! ok
69 !ERROR: Actual procedure argument has interface incompatible with dummy argument 'p=': function results have distinct types: REAL(4) vs INTEGER(4)
72 call s01(procptr()) ! ok
73 !ERROR: Actual procedure argument has interface incompatible with dummy argument 'p=': function results have distinct types: REAL(4) vs INTEGER(4)
74 call s01(intprocptr())
76 call s01(null(p
)) ! ok
77 !ERROR: Actual procedure argument has interface incompatible with dummy argument 'p=': function results have distinct types: REAL(4) vs INTEGER(4)
80 !ERROR: Actual argument associated with procedure dummy argument 'p=' is not a procedure
81 call s01(null(intPtr
))
82 !ERROR: Actual argument associated with procedure dummy argument 'p=' is typeless
84 !ERROR: Actual argument associated with procedure pointer dummy argument 'p=' must be a POINTER unless INTENT(IN)
87 !ERROR: Actual procedure argument has interface incompatible with dummy argument 'p=': function results have distinct types: REAL(4) vs INTEGER(4)
89 !ERROR: Actual argument associated with procedure pointer dummy argument 'p=' must be a POINTER unless INTENT(IN)
92 !ERROR: Actual argument associated with procedure pointer dummy argument 'p=' must be a POINTER unless INTENT(IN)
94 !ERROR: Actual argument associated with procedure pointer dummy argument 'p=' must be a POINTER unless INTENT(IN)
96 !ERROR: Actual argument associated with procedure pointer dummy argument 'p=' must be a POINTER unless INTENT(IN)
99 !ERROR: Actual argument function associated with procedure dummy argument 'p=' is not compatible: function results have distinct types: REAL(4) vs INTEGER(4)
101 !ERROR: Actual argument associated with procedure pointer dummy argument 'p=' must be a POINTER unless INTENT(IN)
104 !ERROR: Actual argument associated with procedure pointer dummy argument 'p=' must be a POINTER unless INTENT(IN)
108 subroutine callsub(s
)
111 subroutine takesrealfunc1(f
)
115 subroutine takesrealfunc2(f
)
118 subroutine forwardproc(p
)
120 external :: p
! function or subroutine not known
124 subroutine test2(unknown
,ds
,drf
,dif
) ! 15.5.2.9(2,3)
125 external :: unknown
, ds
, drf
, dif
128 procedure(callsub
), pointer :: ps
129 procedure(realfunc
), pointer :: prf
130 procedure(intfunc
), pointer :: pif
131 call ds
! now we know that's it's a subroutine
132 call callsub(callsub
) ! ok apart from infinite recursion
133 call callsub(unknown
) ! ok
134 call callsub(ds
) ! ok
135 call callsub(ps
) ! ok
136 call takesrealfunc1(realfunc
) ! ok
137 call takesrealfunc1(unknown
) ! ok
138 call takesrealfunc1(drf
) ! ok
139 call takesrealfunc1(prf
) ! ok
140 call takesrealfunc2(realfunc
) ! ok
141 call takesrealfunc2(unknown
) ! ok
142 call takesrealfunc2(drf
) ! ok
143 call takesrealfunc2(prf
) ! ok
144 call forwardproc(callsub
) ! ok
145 call forwardproc(realfunc
) ! ok
146 call forwardproc(intfunc
) ! ok
147 call forwardproc(unknown
) ! ok
148 call forwardproc(ds
) ! ok
149 call forwardproc(drf
) ! ok
150 call forwardproc(dif
) ! ok
151 call forwardproc(ps
) ! ok
152 call forwardproc(prf
) ! ok
153 call forwardproc(pif
) ! ok
154 !ERROR: Actual argument associated with procedure dummy argument 's=' is a function but must be a subroutine
155 call callsub(realfunc
)
156 !ERROR: Actual argument associated with procedure dummy argument 's=' is a function but must be a subroutine
157 call callsub(intfunc
)
158 !ERROR: Actual argument associated with procedure dummy argument 's=' is a function but must be a subroutine
160 !ERROR: Actual argument associated with procedure dummy argument 's=' is a function but must be a subroutine
162 !ERROR: Actual argument associated with procedure dummy argument 's=' is a function but must be a subroutine
164 !ERROR: Actual argument associated with procedure dummy argument 's=' is a function but must be a subroutine
166 !ERROR: Actual argument associated with procedure dummy argument 'f=' is a subroutine but must be a function
167 call takesrealfunc1(callsub
)
168 !ERROR: Actual argument associated with procedure dummy argument 'f=' is a subroutine but must be a function
169 call takesrealfunc1(ds
)
170 !ERROR: Actual argument associated with procedure dummy argument 'f=' is a subroutine but must be a function
171 call takesrealfunc1(ps
)
172 !ERROR: Actual argument function associated with procedure dummy argument 'f=' is not compatible: function results have distinct types: REAL(4) vs INTEGER(4)
173 call takesrealfunc1(intfunc
)
174 !ERROR: Actual argument function associated with procedure dummy argument 'f=' is not compatible: function results have distinct types: REAL(4) vs INTEGER(4)
175 call takesrealfunc1(dif
)
176 !ERROR: Actual argument function associated with procedure dummy argument 'f=' is not compatible: function results have distinct types: REAL(4) vs INTEGER(4)
177 call takesrealfunc1(pif
)
178 !ERROR: Actual argument function associated with procedure dummy argument 'f=' is not compatible: function results have distinct types: REAL(4) vs INTEGER(4)
179 call takesrealfunc1(intfunc
)
180 !ERROR: Actual argument associated with procedure dummy argument 'f=' is a subroutine but must be a function
181 call takesrealfunc2(callsub
)
182 !ERROR: Actual argument associated with procedure dummy argument 'f=' is a subroutine but must be a function
183 call takesrealfunc2(ds
)
184 !ERROR: Actual argument associated with procedure dummy argument 'f=' is a subroutine but must be a function
185 call takesrealfunc2(ps
)
186 !ERROR: Actual argument function associated with procedure dummy argument 'f=' is not compatible: function results have distinct types: REAL(4) vs INTEGER(4)
187 call takesrealfunc2(intfunc
)
188 !ERROR: Actual argument function associated with procedure dummy argument 'f=' is not compatible: function results have distinct types: REAL(4) vs INTEGER(4)
189 call takesrealfunc2(dif
)
190 !ERROR: Actual argument function associated with procedure dummy argument 'f=' is not compatible: function results have distinct types: REAL(4) vs INTEGER(4)
191 call takesrealfunc2(pif
)
192 !ERROR: Actual argument function associated with procedure dummy argument 'f=' is not compatible: function results have distinct types: REAL(4) vs INTEGER(4)
193 call takesrealfunc2(intfunc
)