2 ! { dg-options "-fdump-tree-original" }
4 ! Tests the fix for PR98498, which was subject to an interpretation request
5 ! as to whether or not the interface operator overrode the intrinsic use.
6 ! (See PR for correspondence)
8 ! Contributed by Paul Thomas <pault@gcc.gnu.org>
14 character(len
=20) :: name
18 interface operator (==)
19 module procedure star_eq
22 interface operator (.not
.)
23 module procedure star_not
27 function star_eq(a
, b
)
29 class(*), intent(in
) :: a
, b
35 if((a
%level
.eq
. b
%level
) .and
. (a
%name
.eq
. b
%name
)) then
41 star_eq
= (a
%level
== b
)
50 class(*), intent(in
) :: a
51 type(pvar
) :: star_not
55 star_not
%level
= -star_not
%level
57 star_not
= pvar ("real", -int(a
))
59 star_not
= pvar ("noname", 0)
72 character(len
= 4, kind
=4) :: c
= "abcd"
73 ! Check that intrinsic use of .not. and == is not overridden.
74 if (.not
.(i
== 2*int (r
))) stop 1
77 ! Test defined operator ==
78 x
= pvar('test 1', 100)
79 y
= pvar('test 1', 100)
80 if (.not
.(x
== y
)) stop 3
81 y
= pvar('test 2', 100)
83 if (x
== r
) stop 5 ! class default gives .false.
84 if (100 == x
) stop 6 ! ditto
85 if (.not
.(x
== 100)) stop 7 ! integer selector gives a%level == b
86 if (i
== "c") stop 8 ! type mismatch => calls star_eq
87 if (c
== "abcd") stop 9 ! kind mismatch => calls star_eq
89 ! Test defined operator .not.
91 if (y
%level
.ne
. -x
%level
) stop 11
93 if (y
%level
.ne
. 0 .and
. trim(y
%name
) .ne
. "noname") stop 12
95 if (y
%level
.ne
. -2 .and
. trim(y
%name
) .ne
. "real") stop 13
97 ! { dg-final { scan-tree-dump-times "star_eq" 14 "original" } }
98 ! { dg-final { scan-tree-dump-times "star_not" 11 "original" } }