1 ! RUN: %S/test_errors.sh %s %t %flang_fc1
3 ! Test restrictions on what subprograms can be used for defined operators.
8 !ERROR: OPERATOR(+) procedure 'add1' must be a function
9 subroutine add1(x
, y
, z
)
10 real, intent(out
) :: x
11 real, intent(in
) :: y
, z
19 logical, intent(in
) :: x
21 real function sub2(x
, y
)
22 logical, intent(in
) :: x
, y
24 !ERROR: OPERATOR(-) function 'sub3' must have one or two dummy arguments
25 real function sub3(x
, y
, z
)
26 real, intent(in
) :: x
, y
, z
29 interface operator(.not
.)
30 !ERROR: OPERATOR(.NOT.) function 'not1' must have one dummy argument
31 real function not1(x
, y
)
32 real, intent(in
) :: x
, y
39 !ERROR: OPERATOR(/) function 'divide' may not have assumed-length CHARACTER(*) result
40 character(*) function divide(x
, y
)
41 character(*), intent(in
) :: x
, y
45 !ERROR: In OPERATOR(<) function 'lt1', dummy argument 'x' must have INTENT(IN) or VALUE attribute
46 !ERROR: In OPERATOR(<) function 'lt1', dummy argument 'y' may not be OPTIONAL
47 logical function lt1(x
, y
)
49 real, value
, optional
:: y
51 !ERROR: In OPERATOR(<) function 'lt2', dummy argument 'y' must be a data object
52 logical function lt2(x
, y
)
53 logical, intent(in
) :: x
65 !ERROR: OPERATOR(+) function 'add' conflicts with intrinsic operator
66 complex function add(x
, y
)
70 !ERROR: OPERATOR(+) function 'plus' conflicts with intrinsic operator
72 complex, intent(in
) :: x
75 interface operator(.not
.)
79 !ERROR: OPERATOR(.NOT.) function 'not2' conflicts with intrinsic operator
80 logical(8) function not2(x
)
81 logical(8), value
:: x
84 interface operator(.and
.)
85 !ERROR: OPERATOR(.AND.) function 'and' conflicts with intrinsic operator
86 real function and(x
, y
)
87 logical(1), value
:: x
88 logical(8), value
:: y
91 interface operator(//)
92 real function concat1(x
, y
)
95 real function concat2(x
, y
)
96 character(kind
=1, len
=4), intent(in
) :: x
97 character(kind
=4, len
=4), intent(in
) :: y
99 !ERROR: OPERATOR(//) function 'concat3' conflicts with intrinsic operator
100 real function concat3(x
, y
)
101 character(kind
=4, len
=4), intent(in
) :: x
102 character(kind
=4, len
=4), intent(in
) :: y