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(realfunc
) :: p
29 !ERROR: A dummy procedure without the POINTER attribute may not have an INTENT attribute
30 procedure(realfunc
), intent(in
) :: p
33 subroutine selemental1(p
)
34 procedure(cos
) :: p
! ok
37 real elemental
function elemfunc(x
)
41 subroutine selemental2(p
)
42 !ERROR: A dummy procedure may not be ELEMENTAL
43 procedure(elemfunc
) :: p
47 procedure(realfunc
), pointer :: procptr
51 procedure(intfunc
), pointer :: intprocptr
55 subroutine test1
! 15.5.2.9(5)
57 procedure(realfunc
), pointer :: p
58 procedure(intfunc
), pointer :: ip
59 integer, pointer :: intPtr
62 call s01(realfunc
) ! ok
63 !ERROR: Actual procedure argument has interface incompatible with dummy argument 'p='
66 call s01(procptr()) ! ok
67 !ERROR: Actual procedure argument has interface incompatible with dummy argument 'p='
68 call s01(intprocptr())
70 call s01(null(p
)) ! ok
71 !ERROR: Actual procedure argument has interface incompatible with dummy argument 'p='
74 !ERROR: Actual argument associated with procedure dummy argument 'p=' is not a procedure
75 call s01(null(intPtr
))
76 !ERROR: Actual argument associated with procedure dummy argument 'p=' is typeless
78 !ERROR: Actual argument associated with procedure pointer dummy argument 'p=' must be a POINTER unless INTENT(IN)
81 !ERROR: Actual procedure argument has interface incompatible with dummy argument 'p='
83 !ERROR: Actual argument associated with procedure pointer dummy argument 'p=' must be a POINTER unless INTENT(IN)
85 !ERROR: Actual argument associated with procedure pointer dummy argument 'p=' must be a POINTER unless INTENT(IN)
87 !ERROR: Actual argument associated with procedure pointer dummy argument 'p=' must be a POINTER unless INTENT(IN)
89 !ERROR: Actual argument associated with procedure pointer dummy argument 'p=' must be a POINTER unless INTENT(IN)
96 subroutine takesrealfunc1(f
)
100 subroutine takesrealfunc2(f
)
103 subroutine forwardproc(p
)
105 external :: p
! function or subroutine not known
109 subroutine test2(unknown
,ds
,drf
,dif
) ! 15.5.2.9(2,3)
110 external :: unknown
, ds
, drf
, dif
113 procedure(callsub
), pointer :: ps
114 procedure(realfunc
), pointer :: prf
115 procedure(intfunc
), pointer :: pif
116 call ds
! now we know that's it's a subroutine
117 call callsub(callsub
) ! ok apart from infinite recursion
118 call callsub(unknown
) ! ok
119 call callsub(ds
) ! ok
120 call callsub(ps
) ! ok
121 call takesrealfunc1(realfunc
) ! ok
122 call takesrealfunc1(unknown
) ! ok
123 call takesrealfunc1(drf
) ! ok
124 call takesrealfunc1(prf
) ! ok
125 call takesrealfunc2(realfunc
) ! ok
126 call takesrealfunc2(unknown
) ! ok
127 call takesrealfunc2(drf
) ! ok
128 call takesrealfunc2(prf
) ! ok
129 call forwardproc(callsub
) ! ok
130 call forwardproc(realfunc
) ! ok
131 call forwardproc(intfunc
) ! ok
132 call forwardproc(unknown
) ! ok
133 call forwardproc(ds
) ! ok
134 call forwardproc(drf
) ! ok
135 call forwardproc(dif
) ! ok
136 call forwardproc(ps
) ! ok
137 call forwardproc(prf
) ! ok
138 call forwardproc(pif
) ! ok
139 !ERROR: Actual argument associated with procedure dummy argument 's=' is a function but must be a subroutine
140 call callsub(realfunc
)
141 !ERROR: Actual argument associated with procedure dummy argument 's=' is a function but must be a subroutine
142 call callsub(intfunc
)
143 !ERROR: Actual argument associated with procedure dummy argument 's=' is a function but must be a subroutine
145 !ERROR: Actual argument associated with procedure dummy argument 's=' is a function but must be a subroutine
147 !ERROR: Actual argument associated with procedure dummy argument 's=' is a function but must be a subroutine
149 !ERROR: Actual argument associated with procedure dummy argument 's=' is a function but must be a subroutine
151 !ERROR: Actual argument associated with procedure dummy argument 'f=' is a subroutine but must be a function
152 call takesrealfunc1(callsub
)
153 !ERROR: Actual argument associated with procedure dummy argument 'f=' is a subroutine but must be a function
154 call takesrealfunc1(ds
)
155 !ERROR: Actual argument associated with procedure dummy argument 'f=' is a subroutine but must be a function
156 call takesrealfunc1(ps
)
157 !ERROR: Actual argument function associated with procedure dummy argument 'f=' has incompatible result type
158 call takesrealfunc1(intfunc
)
159 !ERROR: Actual argument function associated with procedure dummy argument 'f=' has incompatible result type
160 call takesrealfunc1(dif
)
161 !ERROR: Actual argument function associated with procedure dummy argument 'f=' has incompatible result type
162 call takesrealfunc1(pif
)
163 !ERROR: Actual argument function associated with procedure dummy argument 'f=' has incompatible result type
164 call takesrealfunc1(intfunc
)
165 !ERROR: Actual argument associated with procedure dummy argument 'f=' is a subroutine but must be a function
166 call takesrealfunc2(callsub
)
167 !ERROR: Actual argument associated with procedure dummy argument 'f=' is a subroutine but must be a function
168 call takesrealfunc2(ds
)
169 !ERROR: Actual argument associated with procedure dummy argument 'f=' is a subroutine but must be a function
170 call takesrealfunc2(ps
)
171 !ERROR: Actual argument function associated with procedure dummy argument 'f=' has incompatible result type
172 call takesrealfunc2(intfunc
)
173 !ERROR: Actual argument function associated with procedure dummy argument 'f=' has incompatible result type
174 call takesrealfunc2(dif
)
175 !ERROR: Actual argument function associated with procedure dummy argument 'f=' has incompatible result type
176 call takesrealfunc2(pif
)
177 !ERROR: Actual argument function associated with procedure dummy argument 'f=' has incompatible result type
178 call takesrealfunc2(intfunc
)