1 ! RUN: %python %S/test_errors.py %s %flang_fc1
2 ! Test restrictions on what subprograms can be used for defined assignment.
8 !ERROR: Defined assignment procedure 'binding' must be a subroutine
9 generic
:: assignment(=) => binding
10 procedure
:: binding
=> assign_t1
12 procedure
:: assign_t2
13 procedure
:: assign_t3
14 !ERROR: Defined assignment subroutine 'assign_t2' must have two dummy arguments
15 !ERROR: In defined assignment subroutine 'assign_t3', second dummy argument 'y' must have INTENT(IN) or VALUE attribute
16 !ERROR: In defined assignment subroutine 'assign_t4', first dummy argument 'x' must have INTENT(OUT) or INTENT(INOUT)
17 generic
:: assignment(=) => assign_t
, assign_t2
, assign_t3
, assign_t4
18 procedure
:: assign_t4
22 procedure
, nopass
:: assign_t
23 !ERROR: Defined assignment procedure 'assign_t' may not have NOPASS attribute
24 generic
:: assignment(=) => assign_t
27 subroutine assign_t(x
, y
)
28 class(t
), intent(out
) :: x
29 type(t
), intent(in
) :: y
31 logical function assign_t1(x
, y
)
32 class(t
), intent(out
) :: x
33 type(t
), intent(in
) :: y
35 subroutine assign_t2(x
)
36 class(t
), intent(out
) :: x
38 subroutine assign_t3(x
, y
)
39 class(t
), intent(out
) :: x
42 subroutine assign_t4(x
, y
)
44 integer, intent(in
) :: y
51 interface assignment(=)
52 !ERROR: In defined assignment subroutine 's1', dummy argument 'y' may not be OPTIONAL
55 type(t
), intent(out
) :: x
56 real, optional
, intent(in
) :: y
58 !ERROR: In defined assignment subroutine 's2', dummy argument 'y' must be a data object
61 type(t
), intent(out
) :: x
71 ! Detect defined assignment that conflicts with intrinsic assignment
75 interface assignment(=)
76 ! OK - lhs is derived type
77 subroutine assign_tt(x
, y
)
79 type(t
), intent(out
) :: x
80 type(t
), intent(in
) :: y
82 !OK - incompatible types
83 subroutine assign_il(x
, y
)
84 integer, intent(out
) :: x
85 logical, intent(in
) :: y
88 subroutine assign_23(x
, y
)
89 integer, intent(out
) :: x(:,:)
90 integer, intent(in
) :: y(:,:,:)
93 subroutine assign_01(x
, y
)
94 integer, intent(out
) :: x
95 integer, intent(in
) :: y(:)
97 !ERROR: Defined assignment subroutine 'assign_10' conflicts with intrinsic assignment
98 subroutine assign_10(x
, y
)
99 integer, intent(out
) :: x(:)
100 integer, intent(in
) :: y
102 !ERROR: Defined assignment subroutine 'assign_ir' conflicts with intrinsic assignment
103 subroutine assign_ir(x
, y
)
104 integer, intent(out
) :: x
105 real, intent(in
) :: y
107 !ERROR: Defined assignment subroutine 'assign_ii' conflicts with intrinsic assignment
108 subroutine assign_ii(x
, y
)
109 integer(2), intent(out
) :: x
110 integer(1), intent(in
) :: y