aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.9/gcc/testsuite/gfortran.fortran-torture/execute/userop.f90
blob: 4fceb4766857616e1d597dcd996b14739682edaf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
module uops
   implicit none
   interface operator (.foo.)
      module procedure myfoo
   end interface

   interface operator (*)
      module procedure boolmul
   end interface

   interface assignment (=)
      module procedure int2bool
   end interface

contains
function myfoo (lhs, rhs)
   implicit none
   integer myfoo
   integer, intent(in) :: lhs, rhs

   myfoo = lhs + rhs
end function

! This is deliberately different from integer multiplication
function boolmul (lhs, rhs)
   implicit none
   logical boolmul
   logical, intent(IN) :: lhs, rhs

   boolmul = lhs .and. .not. rhs
end function

subroutine int2bool (lhs, rhs)
   implicit none
   logical, intent(out) :: lhs
   integer, intent(in) :: rhs

   lhs = rhs .ne. 0
end subroutine
end module

program me
   use uops
   implicit none
   integer i, j
   logical b, c

   b = .true.
   c = .true.
   if (b * c) call abort
   c = .false.
   if (.not. (b * c)) call abort
   if (c * b) call abort
   b = .false.
   if (b * c) call abort

   i = 0
   b = i
   if (b) call abort
   i = 2
   b = i
   if (.not. b) call abort

   j = 3
   if ((i .foo. j) .ne. 5) call abort
end program