1 ! RUN: %python %S/test_errors.py %s %flang_fc1
2 ! Test restrictions on what subprograms can be used for defined operators.
7 !ERROR: OPERATOR(+) procedure 'add1' must be a function
8 subroutine add1(x
, y
, z
)
10 real, intent(in
) :: y
, z
18 logical, intent(in
) :: x
20 real function sub2(x
, y
)
21 logical, intent(in
) :: x
, y
23 !ERROR: OPERATOR(-) function 'sub3' must have one or two dummy arguments
24 real function sub3(x
, y
, z
)
25 real, intent(in
) :: x
, y
, z
28 interface operator(.not
.)
29 !ERROR: OPERATOR(.NOT.) function 'not1' must have one dummy argument
30 real function not1(x
, y
)
31 real, intent(in
) :: x
, y
38 !ERROR: A function interface may not declare an assumed-length CHARACTER(*) result
39 character(*) function divide(x
, y
)
40 character(*), intent(in
) :: x
, y
44 !ERROR: In OPERATOR(<) function 'lt1', dummy argument 'x' must have INTENT(IN) or VALUE attribute
45 !ERROR: In OPERATOR(<) function 'lt1', dummy argument 'y' may not be OPTIONAL
46 logical function lt1(x
, y
)
48 real, value
, optional
:: y
50 !ERROR: In OPERATOR(<) function 'lt2', dummy argument 'y' must be a data object
51 logical function lt2(x
, y
)
52 logical, intent(in
) :: x
61 subroutine s(alcf1
, alcf2
)
63 character(*) function alcf1(x
, y
)
64 character(*), intent(in
) :: x
, y
66 character(*) function alcf2(x
, y
)
67 character(*), intent(in
) :: x
, y
71 !ERROR: OPERATOR(+) function 'alcf1' may not have assumed-length CHARACTER(*) result
74 !ERROR: OPERATOR(-) function 'alcf2' may not have assumed-length CHARACTER(*) result
75 generic
:: operator(-) => alcf2
81 !ERROR: OPERATOR(+) function 'add' conflicts with intrinsic operator
82 complex function add(x
, y
)
86 !ERROR: OPERATOR(+) function 'plus' conflicts with intrinsic operator
88 complex, intent(in
) :: x
91 interface operator(.not
.)
95 !ERROR: OPERATOR(.NOT.) function 'not2' conflicts with intrinsic operator
96 logical(8) function not2(x
)
97 logical(8), value
:: x
100 interface operator(.and
.)
101 !ERROR: OPERATOR(.AND.) function 'and' conflicts with intrinsic operator
102 real function and(x
, y
)
103 logical(1), value
:: x
104 logical(8), value
:: y
107 interface operator(//)
108 real function concat1(x
, y
)
111 real function concat2(x
, y
)
112 character(kind
=1, len
=4), intent(in
) :: x
113 character(kind
=4, len
=4), intent(in
) :: y
115 !ERROR: OPERATOR(//) function 'concat3' conflicts with intrinsic operator
116 real function concat3(x
, y
)
117 character(kind
=4, len
=4), intent(in
) :: x
118 character(kind
=4, len
=4), intent(in
) :: y