1 ! RUN: %python %S/test_errors.py %s %flang_fc1 -pedantic
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 !PORTABILITY: A dummy procedure should not have an ELEMENTAL intrinsic as its interface
41 procedure(cos
) :: p
! ok
44 real elemental
function elemfunc(x
)
48 subroutine selemental2(p
)
49 !ERROR: A dummy procedure may not be ELEMENTAL
50 procedure(elemfunc
) :: p
54 procedure(realfunc
), pointer :: procptr
58 procedure(intfunc
), pointer :: intprocptr
62 subroutine test1
! 15.5.2.9(5)
64 procedure(realfunc
), pointer :: p
65 procedure(intfunc
), pointer :: ip
66 integer, pointer :: intPtr
69 call s01(realfunc
) ! ok
70 !ERROR: Actual procedure argument has interface incompatible with dummy argument 'p=': function results have distinct types: REAL(4) vs INTEGER(4)
73 call s01(procptr()) ! ok
74 !ERROR: Actual procedure argument has interface incompatible with dummy argument 'p=': function results have distinct types: REAL(4) vs INTEGER(4)
75 call s01(intprocptr())
77 call s01(null(p
)) ! ok
78 !ERROR: Actual procedure argument has interface incompatible with dummy argument 'p=': function results have distinct types: REAL(4) vs INTEGER(4)
81 !ERROR: Actual argument associated with procedure dummy argument 'p=' is not a procedure
82 call s01(null(intPtr
))
83 !ERROR: Actual argument associated with procedure dummy argument 'p=' is typeless
85 !ERROR: Actual argument associated with procedure pointer dummy argument 'p=' must be a pointer unless INTENT(IN)
88 !ERROR: Actual procedure argument has interface incompatible with dummy argument 'p=': function results have distinct types: REAL(4) vs INTEGER(4)
90 !ERROR: Actual argument associated with procedure pointer dummy argument 'p=' must be a pointer unless INTENT(IN)
93 !ERROR: Actual argument associated with procedure pointer dummy argument 'p=' must be a pointer unless INTENT(IN)
95 !ERROR: Actual argument associated with procedure pointer dummy argument 'p=' must be a pointer unless INTENT(IN)
97 !ERROR: Actual argument associated with procedure pointer dummy argument 'p=' must be a pointer unless INTENT(IN)
100 !ERROR: Actual argument function associated with procedure dummy argument 'p=' is not compatible: function results have distinct types: REAL(4) vs INTEGER(4)
102 !ERROR: Actual argument associated with procedure pointer dummy argument 'p=' must be a pointer unless INTENT(IN)
105 !ERROR: Actual argument associated with procedure pointer dummy argument 'p=' must be a pointer unless INTENT(IN)
109 subroutine callsub(s
)
112 subroutine takesrealfunc1(f
)
116 subroutine takesrealfunc2(f
)
119 subroutine forwardproc(p
)
121 external :: p
! function or subroutine not known
125 subroutine test2(unknown
,ds
,drf
,dif
) ! 15.5.2.9(2,3)
126 external :: unknown
, ds
, drf
, dif
129 procedure(callsub
), pointer :: ps
130 procedure(realfunc
), pointer :: prf
131 procedure(intfunc
), pointer :: pif
132 call ds
! now we know that's it's a subroutine
133 call callsub(callsub
) ! ok apart from infinite recursion
134 call callsub(unknown
) ! ok
135 call callsub(ds
) ! ok
136 call callsub(ps
) ! ok
137 call takesrealfunc1(realfunc
) ! ok
138 call takesrealfunc1(unknown
) ! ok
139 call takesrealfunc1(drf
) ! ok
140 call takesrealfunc1(prf
) ! ok
141 call takesrealfunc2(realfunc
) ! ok
142 call takesrealfunc2(unknown
) ! ok
143 call takesrealfunc2(drf
) ! ok
144 call takesrealfunc2(prf
) ! ok
145 call forwardproc(callsub
) ! ok
146 call forwardproc(realfunc
) ! ok
147 call forwardproc(intfunc
) ! ok
148 call forwardproc(unknown
) ! ok
149 call forwardproc(ds
) ! ok
150 call forwardproc(drf
) ! ok
151 call forwardproc(dif
) ! ok
152 call forwardproc(ps
) ! ok
153 call forwardproc(prf
) ! ok
154 call forwardproc(pif
) ! ok
155 !ERROR: Actual argument associated with procedure dummy argument 's=' is a function but must be a subroutine
156 call callsub(realfunc
)
157 !ERROR: Actual argument associated with procedure dummy argument 's=' is a function but must be a subroutine
158 call callsub(intfunc
)
159 !ERROR: Actual argument associated with procedure dummy argument 's=' is a function but must be a subroutine
161 !ERROR: Actual argument associated with procedure dummy argument 's=' is a function but must be a subroutine
163 !ERROR: Actual argument associated with procedure dummy argument 's=' is a function but must be a subroutine
165 !ERROR: Actual argument associated with procedure dummy argument 's=' is a function but must be a subroutine
167 !ERROR: Actual argument associated with procedure dummy argument 'f=' is a subroutine but must be a function
168 call takesrealfunc1(callsub
)
169 !ERROR: Actual argument associated with procedure dummy argument 'f=' is a subroutine but must be a function
170 call takesrealfunc1(ds
)
171 !ERROR: Actual argument associated with procedure dummy argument 'f=' is a subroutine but must be a function
172 call takesrealfunc1(ps
)
173 !ERROR: Actual argument function associated with procedure dummy argument 'f=' is not compatible: function results have distinct types: REAL(4) vs INTEGER(4)
174 call takesrealfunc1(intfunc
)
175 !ERROR: Actual argument function associated with procedure dummy argument 'f=' is not compatible: function results have distinct types: REAL(4) vs INTEGER(4)
176 call takesrealfunc1(dif
)
177 !ERROR: Actual argument function associated with procedure dummy argument 'f=' is not compatible: function results have distinct types: REAL(4) vs INTEGER(4)
178 call takesrealfunc1(pif
)
179 !ERROR: Actual argument function associated with procedure dummy argument 'f=' is not compatible: function results have distinct types: REAL(4) vs INTEGER(4)
180 call takesrealfunc1(intfunc
)
181 !ERROR: Actual argument associated with procedure dummy argument 'f=' is a subroutine but must be a function
182 call takesrealfunc2(callsub
)
183 !ERROR: Actual argument associated with procedure dummy argument 'f=' is a subroutine but must be a function
184 call takesrealfunc2(ds
)
185 !ERROR: Actual argument associated with procedure dummy argument 'f=' is a subroutine but must be a function
186 call takesrealfunc2(ps
)
187 !ERROR: Actual argument function associated with procedure dummy argument 'f=' is not compatible: function results have distinct types: REAL(4) vs INTEGER(4)
188 call takesrealfunc2(intfunc
)
189 !ERROR: Actual argument function associated with procedure dummy argument 'f=' is not compatible: function results have distinct types: REAL(4) vs INTEGER(4)
190 call takesrealfunc2(dif
)
191 !ERROR: Actual argument function associated with procedure dummy argument 'f=' is not compatible: function results have distinct types: REAL(4) vs INTEGER(4)
192 call takesrealfunc2(pif
)
193 !ERROR: Actual argument function associated with procedure dummy argument 'f=' is not compatible: function results have distinct types: REAL(4) vs INTEGER(4)
194 call takesrealfunc2(intfunc
)