1 ! RUN: %python %S/test_errors.py %s %flang_fc1
2 ! Test various conditions in C1158.
9 type, extends(t1
) :: t2
15 class(*), pointer :: ptr
16 class(t1
), pointer :: p_or_c
17 !vector subscript related
18 class(t1
),DIMENSION(:,:),allocatable
::array1
19 class(t2
),DIMENSION(:,:),allocatable
::array2
20 integer, dimension(2) :: V
25 ! A) associate with function, i.e (other than variables)
26 select
type ( y
=> fun(1) )
31 select
type ( y
=> fun(1) )
35 call sub_with_in_and_inout_param(y
,y
) !VDC
38 select
type ( y
=> (fun(1)) )
40 !ERROR: Left-hand side of assignment is not definable
41 !BECAUSE: 'y' is construct associated with an expression
44 !ERROR: Actual argument associated with INTENT(IN OUT) dummy argument 'z=' is not definable
45 !BECAUSE: 'y' is construct associated with an expression
46 call sub_with_in_and_inout_param(y
,y
) !VDC
49 ! B) associated with a variable:
51 select
type ( a
=> p_or_c
)
56 select
type ( a
=> p_or_c
)
60 !C)Associate with with vector subscript
61 select
type (b
=> array1(V
,2))
63 !ERROR: Left-hand side of assignment is not definable
64 !BECAUSE: Construct association 'b' has a vector subscript
67 !ERROR: Actual argument associated with INTENT(IN OUT) dummy argument 'z=' is not definable
68 !BECAUSE: Variable 'b' has a vector subscript
69 call sub_with_in_and_inout_param_vector(b
,b
) !VDC
71 select
type(b
=> foo(1) )
73 !ERROR: Left-hand side of assignment is not definable
74 !BECAUSE: 'b' is construct associated with an expression
77 !ERROR: Actual argument associated with INTENT(IN OUT) dummy argument 'z=' is not definable
78 !BECAUSE: 'b' is construct associated with an expression
79 call sub_with_in_and_inout_param_vector(b
,b
) !VDC
82 !D) Have no association and should be ok.
83 !1. points to function
90 !2. points to variable
100 class(t1
),pointer :: fun
113 class(t1
),DIMENSION(:),allocatable
:: foo
114 integer, dimension(2) :: U
119 foo
= array2(2,U
) ! ok: t2 extends t1
124 class(t2
),DIMENSION(:),allocatable
:: foo2
125 !ERROR: No intrinsic or user-defined ASSIGNMENT(=) matches operand types CLASS(t2) and CLASS(t1)
129 subroutine sub_with_in_and_inout_param(y
, z
)
130 type(t2
), INTENT(IN
) :: y
131 class(t2
), INTENT(INOUT
) :: z
135 subroutine sub_with_in_and_inout_param_vector(y
, z
)
136 type(t2
),DIMENSION(:), INTENT(IN
) :: y
137 class(t2
),DIMENSION(:), INTENT(INOUT
) :: z