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 type, abstract
, bind(c
) :: badAbstract1
9 !ERROR: An ABSTRACT derived type must be extensible
10 type, abstract
:: badAbstract2
12 real :: badAbstract2Field
14 type, abstract
:: abstract
16 !ERROR: DEFERRED is required when an interface-name is provided
17 procedure(s1
), pass
:: ab1
18 !ERROR: Type-bound procedure 'ab3' may not be both DEFERRED and NON_OVERRIDABLE
19 procedure(s1
), deferred
, non_overridable
:: ab3
20 !ERROR: DEFERRED is only allowed when an interface-name is provided
21 procedure
, deferred
, non_overridable
:: ab4
=> s1
25 procedure
, non_overridable
, nopass
:: no1
=> s1
27 type, extends(nonoverride
) :: nonoverride2
29 type, extends(nonoverride2
) :: nonoverride3
31 !ERROR: Override of NON_OVERRIDABLE 'no1' is not permitted
32 procedure
, nopass
:: no1
=> s1
34 type, abstract
:: missing
36 procedure(s4
), deferred
:: am1
38 !ERROR: Non-ABSTRACT extension of ABSTRACT derived type 'missing' lacks a binding for DEFERRED procedure 'am1'
39 type, extends(missing
) :: concrete
41 type, extends(missing
) :: intermediate
43 procedure
:: am1
=> s7
45 type, extends(intermediate
) :: concrete2
! ensure no false missing binding error
47 type, bind(c
) :: inextensible1
49 !ERROR: The parent type is not extensible
50 type, extends(inextensible1
) :: badExtends1
54 real :: inextensible2Field
56 !ERROR: The parent type is not extensible
57 type, extends(inextensible2
) :: badExtends2
59 !ERROR: Derived type 'real' not found
60 type, extends(real) :: badExtends3
65 !ERROR: Procedure bound to non-ABSTRACT derived type 'base' may not be DEFERRED
66 procedure(s2
), deferred
:: bb1
67 !ERROR: DEFERRED is only allowed when an interface-name is provided
68 procedure
, deferred
:: bb2
=> s2
70 type, extends(base
) :: extension
72 !ERROR: A type-bound procedure binding may not have the same name as a parent component
73 procedure
:: component
=> s3
77 procedure
, nopass
:: tbp
=> s1
79 type, extends(nopassBase
) :: passExtends
81 !ERROR: A passed-argument type-bound procedure may not override a NOPASS procedure
82 procedure
:: tbp
=> s5
86 procedure
:: tbp
=> s6
88 type, extends(passBase
) :: nopassExtends
90 !ERROR: A NOPASS type-bound procedure may not override a passed-argument procedure
91 procedure
, nopass
:: tbp
=> s1
95 class(abstract
), intent(in
) :: x
98 class(base
), intent(in
) :: x
101 class(extension
), intent(in
) :: x
104 class(missing
), intent(in
) :: x
107 class(passExtends
), intent(in
) :: x
110 class(passBase
), intent(in
) :: x
113 class(intermediate
), intent(in
) :: x
125 !ERROR: The binding of 'tbp' ('g') must be either an accessible module procedure or an external procedure with an explicit interface
126 procedure
,pass(x
) :: tbp
=> g
131 class(t
),intent(in
) :: x
139 !ERROR: Procedure binding 'proc' with no dummy arguments must have NOPASS attribute
142 type,extends(parent
) :: child
144 !ERROR: Procedure binding 'proc' with no dummy arguments must have NOPASS attribute
158 !ERROR: Cannot use an alternate return as the passed-object dummy argument
170 ! Check to see that alternate returns work with default PASS arguments
171 subroutine b(this
, *)
180 !ERROR: Passed-object dummy argument 'passarg' of procedure 'b' must be of type 't' but is 'INTEGER(4)'
181 procedure
, pass(passArg
) :: b
184 subroutine b(*, passArg
)
193 !ERROR: Passed-object dummy argument 'passarg' of procedure 'b' must be polymorphic because 't' is extensible
194 procedure
, pass(passArg
) :: b
197 subroutine b(*, passArg
)
206 ! Check to see that alternate returns work with PASS arguments
207 procedure
, pass(passArg
) :: b
210 subroutine b(*, passArg
)
218 type,extends(t
) :: t2