1 ! RUN: %python %S/test_errors.py %s %flang_fc1
2 ! Confirm enforcement of constraints and restrictions in 7.5.7.3
3 ! and C733, C734 and C779, C780, C782, C783, C784, and C785.
6 !ERROR: An ABSTRACT derived type must be extensible
7 !PORTABILITY: A derived type with the BIND attribute is empty
8 type, abstract
, bind(c
) :: badAbstract1
10 !ERROR: An ABSTRACT derived type must be extensible
11 type, abstract
:: badAbstract2
13 real :: badAbstract2Field
15 type, abstract
:: abstract
17 !ERROR: DEFERRED is required when an interface-name is provided
18 procedure(s1
), pass
:: ab1
19 !ERROR: Type-bound procedure 'ab3' may not be both DEFERRED and NON_OVERRIDABLE
20 procedure(s1
), deferred
, non_overridable
:: ab3
21 !ERROR: DEFERRED is only allowed when an interface-name is provided
22 procedure
, deferred
, non_overridable
:: ab4
=> s1
26 procedure
, non_overridable
, nopass
:: no1
=> s1
28 type, extends(nonoverride
) :: nonoverride2
30 type, extends(nonoverride2
) :: nonoverride3
32 !ERROR: Override of NON_OVERRIDABLE 'no1' is not permitted
33 procedure
, nopass
:: no1
=> s1
35 type, abstract
:: missing
37 procedure(s4
), deferred
:: am1
39 !ERROR: Non-ABSTRACT extension of ABSTRACT derived type 'missing' lacks a binding for DEFERRED procedure 'am1'
40 type, extends(missing
) :: concrete
42 type, extends(missing
) :: intermediate
44 procedure
:: am1
=> s7
46 type, extends(intermediate
) :: concrete2
! ensure no false missing binding error
48 !WARNING: A derived type with the BIND attribute is empty
49 type, bind(c
) :: inextensible1
51 !ERROR: The parent type is not extensible
52 type, extends(inextensible1
) :: badExtends1
56 real :: inextensible2Field
58 !ERROR: The parent type is not extensible
59 type, extends(inextensible2
) :: badExtends2
61 !ERROR: Derived type 'real' not found
62 type, extends(real) :: badExtends3
67 !ERROR: Procedure bound to non-ABSTRACT derived type 'base' may not be DEFERRED
68 procedure(s2
), deferred
:: bb1
69 !ERROR: DEFERRED is only allowed when an interface-name is provided
70 procedure
, deferred
:: bb2
=> s2
72 type, extends(base
) :: extension
74 !ERROR: A type-bound procedure binding may not have the same name as a parent component
75 procedure
:: component
=> s3
79 procedure
, nopass
:: tbp
=> s1
81 type, extends(nopassBase
) :: passExtends
83 !ERROR: A passed-argument type-bound procedure may not override a NOPASS procedure
84 procedure
:: tbp
=> s5
88 procedure
:: tbp
=> s6
90 type, extends(passBase
) :: nopassExtends
92 !ERROR: A NOPASS type-bound procedure may not override a passed-argument procedure
93 procedure
, nopass
:: tbp
=> s1
97 class(abstract
), intent(in
) :: x
100 class(base
), intent(in
) :: x
103 class(extension
), intent(in
) :: x
106 class(missing
), intent(in
) :: x
109 class(passExtends
), intent(in
) :: x
112 class(passBase
), intent(in
) :: x
115 class(intermediate
), intent(in
) :: x
127 !ERROR: The binding of 'tbp' ('g') must be either an accessible module procedure or an external procedure with an explicit interface
128 procedure
,pass(x
) :: tbp
=> g
133 class(t
),intent(in
) :: x
141 !ERROR: Procedure binding 'proc' with no dummy arguments must have NOPASS attribute
144 type,extends(parent
) :: child
146 !ERROR: Procedure binding 'proc' with no dummy arguments must have NOPASS attribute
160 !ERROR: Cannot use an alternate return as the passed-object dummy argument
172 ! Check to see that alternate returns work with default PASS arguments
173 subroutine b(this
, *)
182 !ERROR: Passed-object dummy argument 'passarg' of procedure 'b' must be of type 't' but is 'INTEGER(4)'
183 procedure
, pass(passArg
) :: b
186 subroutine b(*, passArg
)
195 !ERROR: Passed-object dummy argument 'passarg' of procedure 'b' must be polymorphic because 't' is extensible
196 procedure
, pass(passArg
) :: b
199 subroutine b(*, passArg
)
208 ! Check to see that alternate returns work with PASS arguments
209 procedure
, pass(passArg
) :: b
212 subroutine b(*, passArg
)
218 module m8
! C1529 - warning only
220 procedure(mysubr
), pointer, nopass
:: pp
222 procedure
, nopass
:: tbp
=> mysubr
229 !PORTABILITY: Base of NOPASS type-bound procedure reference should be scalar
231 !ERROR: Base of procedure component reference must be scalar
239 procedure
, public
:: tbp
=> sub1
241 type, extends(t1
) :: t2
243 !ERROR: A PRIVATE procedure may not override a PUBLIC procedure
244 procedure
, private
:: tbp
=> sub2
248 class(t1
), intent(in
) :: x
251 class(t2
), intent(in
) :: x
258 procedure
:: tbp
=> sub1
262 class(t1
), intent(in
) :: x
267 type, extends(t1
) :: t2
269 !ERROR: A PRIVATE procedure may not override an accessible procedure
270 procedure
, private
:: tbp
=> sub2
274 class(t2
), intent(in
) :: x
280 type,extends(t
) :: t2