1 ! RUN: %S/test_errors.sh %s %t %flang_fc1
3 ! Confirm enforcement of constraints and restrictions in 7.5.7.3
4 ! and C733, C734 and C779, C780, C782, C783, C784, and C785.
7 !ERROR: An ABSTRACT derived type must be extensible
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 type, bind(c
) :: inextensible1
50 !ERROR: The parent type is not extensible
51 type, extends(inextensible1
) :: badExtends1
55 real :: inextensible2Field
57 !ERROR: The parent type is not extensible
58 type, extends(inextensible2
) :: badExtends2
60 !ERROR: Derived type 'real' not found
61 type, extends(real) :: badExtends3
66 !ERROR: Procedure bound to non-ABSTRACT derived type 'base' may not be DEFERRED
67 procedure(s2
), deferred
:: bb1
68 !ERROR: DEFERRED is only allowed when an interface-name is provided
69 procedure
, deferred
:: bb2
=> s2
71 type, extends(base
) :: extension
73 !ERROR: A type-bound procedure binding may not have the same name as a parent component
74 procedure
:: component
=> s3
78 procedure
, nopass
:: tbp
=> s1
80 type, extends(nopassBase
) :: passExtends
82 !ERROR: A passed-argument type-bound procedure may not override a NOPASS procedure
83 procedure
:: tbp
=> s5
87 procedure
:: tbp
=> s6
89 type, extends(passBase
) :: nopassExtends
91 !ERROR: A NOPASS type-bound procedure may not override a passed-argument procedure
92 procedure
, nopass
:: tbp
=> s1
96 class(abstract
), intent(in
) :: x
99 class(base
), intent(in
) :: x
102 class(extension
), intent(in
) :: x
105 class(missing
), intent(in
) :: x
108 class(passExtends
), intent(in
) :: x
111 class(passBase
), intent(in
) :: x
114 class(intermediate
), intent(in
) :: x
126 !ERROR: The binding of 'tbp' ('g') must be either an accessible module procedure or an external procedure with an explicit interface
127 procedure
,pass(x
) :: tbp
=> g
132 class(t
),intent(in
) :: x
140 !ERROR: Procedure binding 'proc' with no dummy arguments must have NOPASS attribute
143 type,extends(parent
) :: child
145 !ERROR: Procedure binding 'proc' with no dummy arguments must have NOPASS attribute
159 !ERROR: Cannot use an alternate return as the passed-object dummy argument
171 ! Check to see that alternate returns work with default PASS arguments
172 subroutine b(this
, *)
181 !ERROR: Passed-object dummy argument 'passarg' of procedure 'b' must be of type 't' but is 'INTEGER(4)'
182 procedure
, pass(passArg
) :: b
185 subroutine b(*, passArg
)
194 !ERROR: Passed-object dummy argument 'passarg' of procedure 'b' must be polymorphic because 't' is extensible
195 procedure
, pass(passArg
) :: b
198 subroutine b(*, passArg
)
207 ! Check to see that alternate returns work with PASS arguments
208 procedure
, pass(passArg
) :: b
211 subroutine b(*, passArg
)
219 type,extends(t
) :: t2