summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gfortran.fortran-torture/execute/userop.f90
diff options
context:
space:
mode:
authorupstream source tree <ports@midipix.org>2015-03-15 20:14:05 -0400
committerupstream source tree <ports@midipix.org>2015-03-15 20:14:05 -0400
commit554fd8c5195424bdbcabf5de30fdc183aba391bd (patch)
tree976dc5ab7fddf506dadce60ae936f43f58787092 /gcc/testsuite/gfortran.fortran-torture/execute/userop.f90
downloadcbb-gcc-4.6.4-554fd8c5195424bdbcabf5de30fdc183aba391bd.tar.bz2
cbb-gcc-4.6.4-554fd8c5195424bdbcabf5de30fdc183aba391bd.tar.xz
obtained gcc-4.6.4.tar.bz2 from upstream website;upstream
verified gcc-4.6.4.tar.bz2.sig; imported gcc-4.6.4 source tree from verified upstream tarball. downloading a git-generated archive based on the 'upstream' tag should provide you with a source tree that is binary identical to the one extracted from the above tarball. if you have obtained the source via the command 'git clone', however, do note that line-endings of files in your working directory might differ from line-endings of the respective files in the upstream repository.
Diffstat (limited to 'gcc/testsuite/gfortran.fortran-torture/execute/userop.f90')
-rw-r--r--gcc/testsuite/gfortran.fortran-torture/execute/userop.f9067
1 files changed, 67 insertions, 0 deletions
diff --git a/gcc/testsuite/gfortran.fortran-torture/execute/userop.f90 b/gcc/testsuite/gfortran.fortran-torture/execute/userop.f90
new file mode 100644
index 000000000..4fceb4766
--- /dev/null
+++ b/gcc/testsuite/gfortran.fortran-torture/execute/userop.f90
@@ -0,0 +1,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
+