1 ! RUN: %S/test_errors.sh %s %t %flang_fc1
3 ! Test 15.5.2.9(2,3,5) dummy procedure requirements
5 ! An entity with the INTENT attribute shall be a dummy data object or a
6 ! dummy procedure pointer.
11 integer function intfunc(x
)
12 integer, intent(in
) :: x
15 real function realfunc(x
)
21 procedure(realfunc
), pointer, intent(in
) :: p
24 procedure(realfunc
), pointer :: p
27 procedure(realfunc
) :: p
30 !ERROR: A dummy procedure without the POINTER attribute may not have an INTENT attribute
31 procedure(realfunc
), intent(in
) :: p
34 subroutine selemental1(p
)
35 procedure(cos
) :: p
! ok
38 real elemental
function elemfunc(x
)
42 subroutine selemental2(p
)
43 !ERROR: A dummy procedure may not be ELEMENTAL
44 procedure(elemfunc
) :: p
48 procedure(realfunc
), pointer :: procptr
52 procedure(intfunc
), pointer :: intprocptr
56 subroutine test1
! 15.5.2.9(5)
58 procedure(realfunc
), pointer :: p
59 procedure(intfunc
), pointer :: ip
60 integer, pointer :: intPtr
62 external :: extfuncPtr
66 call s01(realfunc
) ! ok
67 !ERROR: Actual procedure argument has interface incompatible with dummy argument 'p='
70 call s01(procptr()) ! ok
71 !ERROR: Actual procedure argument has interface incompatible with dummy argument 'p='
72 call s01(intprocptr())
74 call s01(null(p
)) ! ok
75 !ERROR: Actual procedure argument has interface incompatible with dummy argument 'p='
78 !ERROR: Actual argument associated with procedure dummy argument 'p=' is not a procedure
79 call s01(null(intPtr
))
80 !ERROR: Actual argument associated with procedure dummy argument 'p=' is typeless
82 !ERROR: Actual procedure argument has an implicit interface which is not known to be compatible with dummy argument 'p=' which has an explicit interface
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='
89 !ERROR: Actual argument associated with procedure pointer dummy argument 'p=' must be a POINTER unless INTENT(IN)
91 !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 procedure argument has an implicit interface which is not known to be compatible with dummy argument 'p=' which has an explicit interface
99 !ERROR: Actual procedure argument has an implicit interface which is not known to be compatible with dummy argument 'p=' which has an explicit interface
103 subroutine callsub(s
)
106 subroutine takesrealfunc1(f
)
110 subroutine takesrealfunc2(f
)
113 subroutine forwardproc(p
)
115 external :: p
! function or subroutine not known
119 subroutine test2(unknown
,ds
,drf
,dif
) ! 15.5.2.9(2,3)
120 external :: unknown
, ds
, drf
, dif
123 procedure(callsub
), pointer :: ps
124 procedure(realfunc
), pointer :: prf
125 procedure(intfunc
), pointer :: pif
126 call ds
! now we know that's it's a subroutine
127 call callsub(callsub
) ! ok apart from infinite recursion
128 call callsub(unknown
) ! ok
129 call callsub(ds
) ! ok
130 call callsub(ps
) ! ok
131 call takesrealfunc1(realfunc
) ! ok
132 call takesrealfunc1(unknown
) ! ok
133 call takesrealfunc1(drf
) ! ok
134 call takesrealfunc1(prf
) ! ok
135 call takesrealfunc2(realfunc
) ! ok
136 call takesrealfunc2(unknown
) ! ok
137 call takesrealfunc2(drf
) ! ok
138 call takesrealfunc2(prf
) ! ok
139 call forwardproc(callsub
) ! ok
140 call forwardproc(realfunc
) ! ok
141 call forwardproc(intfunc
) ! ok
142 call forwardproc(unknown
) ! ok
143 call forwardproc(ds
) ! ok
144 call forwardproc(drf
) ! ok
145 call forwardproc(dif
) ! ok
146 call forwardproc(ps
) ! ok
147 call forwardproc(prf
) ! ok
148 call forwardproc(pif
) ! ok
149 !ERROR: Actual argument associated with procedure dummy argument 's=' is a function but must be a subroutine
150 call callsub(realfunc
)
151 !ERROR: Actual argument associated with procedure dummy argument 's=' is a function but must be a subroutine
152 call callsub(intfunc
)
153 !ERROR: Actual argument associated with procedure dummy argument 's=' is a function but must be a subroutine
155 !ERROR: Actual argument associated with procedure dummy argument 's=' is a function but must be a subroutine
157 !ERROR: Actual argument associated with procedure dummy argument 's=' is a function but must be a subroutine
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 'f=' is a subroutine but must be a function
162 call takesrealfunc1(callsub
)
163 !ERROR: Actual argument associated with procedure dummy argument 'f=' is a subroutine but must be a function
164 call takesrealfunc1(ds
)
165 !ERROR: Actual argument associated with procedure dummy argument 'f=' is a subroutine but must be a function
166 call takesrealfunc1(ps
)
167 !ERROR: Actual argument function associated with procedure dummy argument 'f=' has incompatible result type
168 call takesrealfunc1(intfunc
)
169 !ERROR: Actual argument function associated with procedure dummy argument 'f=' has incompatible result type
170 call takesrealfunc1(dif
)
171 !ERROR: Actual argument function associated with procedure dummy argument 'f=' has incompatible result type
172 call takesrealfunc1(pif
)
173 !ERROR: Actual argument function associated with procedure dummy argument 'f=' has incompatible result type
174 call takesrealfunc1(intfunc
)
175 !ERROR: Actual argument associated with procedure dummy argument 'f=' is a subroutine but must be a function
176 call takesrealfunc2(callsub
)
177 !ERROR: Actual argument associated with procedure dummy argument 'f=' is a subroutine but must be a function
178 call takesrealfunc2(ds
)
179 !ERROR: Actual argument associated with procedure dummy argument 'f=' is a subroutine but must be a function
180 call takesrealfunc2(ps
)
181 !ERROR: Actual argument function associated with procedure dummy argument 'f=' has incompatible result type
182 call takesrealfunc2(intfunc
)
183 !ERROR: Actual argument function associated with procedure dummy argument 'f=' has incompatible result type
184 call takesrealfunc2(dif
)
185 !ERROR: Actual argument function associated with procedure dummy argument 'f=' has incompatible result type
186 call takesrealfunc2(pif
)
187 !ERROR: Actual argument function associated with procedure dummy argument 'f=' has incompatible result type
188 call takesrealfunc2(intfunc
)