1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302
|
! RUN: %python %S/test_errors.py %s %flang_fc1
! Confirm enforcement of constraints and restrictions in 7.5.7.3
! and C733, C734 and C779, C780, C782, C783, C784, and C785.
module m
!ERROR: An ABSTRACT derived type must be extensible
!PORTABILITY: A derived type with the BIND attribute is empty
type, abstract, bind(c) :: badAbstract1
end type
!ERROR: An ABSTRACT derived type must be extensible
type, abstract :: badAbstract2
sequence
real :: badAbstract2Field
end type
type, abstract :: abstract
contains
!ERROR: DEFERRED is required when an interface-name is provided
procedure(s1), pass :: ab1
!ERROR: Type-bound procedure 'ab3' may not be both DEFERRED and NON_OVERRIDABLE
procedure(s1), deferred, non_overridable :: ab3
!ERROR: DEFERRED is only allowed when an interface-name is provided
procedure, deferred, non_overridable :: ab4 => s1
end type
type :: nonoverride
contains
procedure, non_overridable, nopass :: no1 => s1
end type
type, extends(nonoverride) :: nonoverride2
end type
type, extends(nonoverride2) :: nonoverride3
contains
!ERROR: Override of NON_OVERRIDABLE 'no1' is not permitted
procedure, nopass :: no1 => s1
end type
type, abstract :: missing
contains
procedure(s4), deferred :: am1
end type
!ERROR: Non-ABSTRACT extension of ABSTRACT derived type 'missing' lacks a binding for DEFERRED procedure 'am1'
type, extends(missing) :: concrete
end type
type, extends(missing) :: intermediate
contains
procedure :: am1 => s7
end type
type, extends(intermediate) :: concrete2 ! ensure no false missing binding error
end type
!WARNING: A derived type with the BIND attribute is empty
type, bind(c) :: inextensible1
end type
!ERROR: The parent type is not extensible
type, extends(inextensible1) :: badExtends1
end type
type :: inextensible2
sequence
real :: inextensible2Field
end type
!ERROR: The parent type is not extensible
type, extends(inextensible2) :: badExtends2
end type
!ERROR: Derived type 'real' not found
type, extends(real) :: badExtends3
end type
type :: base
real :: component
contains
!ERROR: Procedure bound to non-ABSTRACT derived type 'base' may not be DEFERRED
procedure(s2), deferred :: bb1
!ERROR: DEFERRED is only allowed when an interface-name is provided
procedure, deferred :: bb2 => s2
end type
type, extends(base) :: extension
contains
!ERROR: A type-bound procedure binding may not have the same name as a parent component
procedure :: component => s3
end type
type :: nopassBase
contains
procedure, nopass :: tbp => s1
end type
type, extends(nopassBase) :: passExtends
contains
!ERROR: A passed-argument type-bound procedure may not override a NOPASS procedure
procedure :: tbp => s5
end type
type :: passBase
contains
procedure :: tbp => s6
end type
type, extends(passBase) :: nopassExtends
contains
!ERROR: A NOPASS type-bound procedure may not override a passed-argument procedure
procedure, nopass :: tbp => s1
end type
contains
subroutine s1(x)
class(abstract), intent(in) :: x
end subroutine s1
subroutine s2(x)
class(base), intent(in) :: x
end subroutine s2
subroutine s3(x)
class(extension), intent(in) :: x
end subroutine s3
subroutine s4(x)
class(missing), intent(in) :: x
end subroutine s4
subroutine s5(x)
class(passExtends), intent(in) :: x
end subroutine s5
subroutine s6(x)
class(passBase), intent(in) :: x
end subroutine s6
subroutine s7(x)
class(intermediate), intent(in) :: x
end subroutine s7
end module
module m1
implicit none
interface g
module procedure mp
end interface g
type t
contains
!ERROR: The binding of 'tbp' ('g') must be either an accessible module procedure or an external procedure with an explicit interface
procedure,pass(x) :: tbp => g
end type t
contains
subroutine mp(x)
class(t),intent(in) :: x
end subroutine
end module m1
module m2
type parent
real realField
contains
!ERROR: Procedure binding 'proc' with no dummy arguments must have NOPASS attribute
procedure proc
end type parent
type,extends(parent) :: child
contains
!ERROR: Procedure binding 'proc' with no dummy arguments must have NOPASS attribute
procedure proc
end type child
contains
subroutine proc
end subroutine
end module m2
module m3
type t
contains
procedure b
end type
contains
!ERROR: Cannot use an alternate return as the passed-object dummy argument
subroutine b(*)
return 1
end subroutine
end module m3
module m4
type t
contains
procedure b
end type
contains
! Check to see that alternate returns work with default PASS arguments
subroutine b(this, *)
class(t) :: this
return 1
end subroutine
end module m4
module m5
type t
contains
!ERROR: Passed-object dummy argument 'passarg' of procedure 'b' must be of type 't' but is 'INTEGER(4)'
procedure, pass(passArg) :: b
end type
contains
subroutine b(*, passArg)
integer :: passArg
return 1
end subroutine
end module m5
module m6
type t
contains
!ERROR: Passed-object dummy argument 'passarg' of procedure 'b' must be polymorphic because 't' is extensible
procedure, pass(passArg) :: b
end type
contains
subroutine b(*, passArg)
type(t) :: passArg
return 1
end subroutine
end module m6
module m7
type t
contains
! Check to see that alternate returns work with PASS arguments
procedure, pass(passArg) :: b
end type
contains
subroutine b(*, passArg)
class(t) :: passArg
return 1
end subroutine
end module m7
module m8 ! C1529 - warning only
type t
procedure(mysubr), pointer, nopass :: pp
contains
procedure, nopass :: tbp => mysubr
end type
contains
subroutine mysubr
end subroutine
subroutine test
type(t) a(2)
!PORTABILITY: Base of NOPASS type-bound procedure reference should be scalar
call a%tbp
!ERROR: Base of procedure component reference must be scalar
call a%pp
end subroutine
end module
module m9
type t1
contains
procedure, public :: tbp => sub1
end type
type, extends(t1) :: t2
contains
!ERROR: A PRIVATE procedure may not override a PUBLIC procedure
procedure, private :: tbp => sub2
end type
contains
subroutine sub1(x)
class(t1), intent(in) :: x
end subroutine
subroutine sub2(x)
class(t2), intent(in) :: x
end subroutine
end module
module m10a
type t1
contains
procedure :: tbp => sub1
end type
contains
subroutine sub1(x)
class(t1), intent(in) :: x
end subroutine
end module
module m10b
use m10a
type, extends(t1) :: t2
contains
!ERROR: A PRIVATE procedure may not override an accessible procedure
procedure, private :: tbp => sub2
end type
contains
subroutine sub2(x)
class(t2), intent(in) :: x
end subroutine
end module
module m11
type t1
contains
procedure, nopass :: tbp => t1p
end type
type, extends(t1) :: t2
contains
private
!ERROR: A PRIVATE procedure may not override a PUBLIC procedure
procedure, nopass :: tbp => t2p
end type
contains
subroutine t1p
end
subroutine t2p
end
end
program test
use m1
type,extends(t) :: t2
end type
type(t2) a
call a%tbp
end program
|