aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.8/gcc/testsuite/gfortran.dg/intrinsic_sign_2.f90
diff options
context:
space:
mode:
authorBen Cheng <bccheng@google.com>2013-03-28 11:14:20 -0700
committerBen Cheng <bccheng@google.com>2013-03-28 12:40:33 -0700
commitaf0c51ac87ab2a87caa03fa108f0d164987a2764 (patch)
tree4b8b470f7c5b69642fdab8d0aa1fbc148d02196b /gcc-4.8/gcc/testsuite/gfortran.dg/intrinsic_sign_2.f90
parentd87cae247d39ebf4f5a6bf25c932a14d2fdb9384 (diff)
downloadtoolchain_gcc-af0c51ac87ab2a87caa03fa108f0d164987a2764.tar.gz
toolchain_gcc-af0c51ac87ab2a87caa03fa108f0d164987a2764.tar.bz2
toolchain_gcc-af0c51ac87ab2a87caa03fa108f0d164987a2764.zip
[GCC 4.8] Initial check-in of GCC 4.8.0
Change-Id: I0719d8a6d0f69b367a6ab6f10eb75622dbf12771
Diffstat (limited to 'gcc-4.8/gcc/testsuite/gfortran.dg/intrinsic_sign_2.f90')
-rw-r--r--gcc-4.8/gcc/testsuite/gfortran.dg/intrinsic_sign_2.f9069
1 files changed, 69 insertions, 0 deletions
diff --git a/gcc-4.8/gcc/testsuite/gfortran.dg/intrinsic_sign_2.f90 b/gcc-4.8/gcc/testsuite/gfortran.dg/intrinsic_sign_2.f90
new file mode 100644
index 000000000..0bc9b07b8
--- /dev/null
+++ b/gcc-4.8/gcc/testsuite/gfortran.dg/intrinsic_sign_2.f90
@@ -0,0 +1,69 @@
+! { dg-do run }
+! Testcase for SIGN() with integer arguments
+! Check that:
+! + SIGN() evaluates its arguments only once
+! + SIGN() works on large values
+! + SIGN() works with parameter arguments
+! Contributed by FX Coudert <fxcoudert@gmail.com>
+program sign1
+ implicit none
+ integer(kind=1), parameter :: one1 = 1_1, mone1 = -1_1
+ integer(kind=2), parameter :: one2 = 1_2, mone2 = -1_2
+ integer(kind=4), parameter :: one4 = 1_4, mone4 = -1_4
+ integer(kind=8), parameter :: one8 = 1_8, mone8 = -1_8
+ integer(kind=1) :: i1, j1
+ integer(kind=2) :: i2, j2
+ integer(kind=4) :: i4, j4
+ integer(kind=8) :: i8, j8
+ integer :: i = 1
+
+ i1 = huge(0_1) ; j1 = -huge(0_1)
+ if (sign(i1, j1) /= j1) call abort()
+ if (sign(j1, i1) /= i1) call abort()
+ if (sign(i1,one1) /= i1 .or. sign(j1,one1) /= i1) call abort()
+ if (sign(i1,mone1) /= j1 .or. sign(j1,mone1) /= j1) call abort()
+
+ i2 = huge(0_2) ; j2 = -huge(0_2)
+ if (sign(i2, j2) /= j2) call abort()
+ if (sign(j2, i2) /= i2) call abort()
+ if (sign(i2,one2) /= i2 .or. sign(j2,one2) /= i2) call abort()
+ if (sign(i2,mone2) /= j2 .or. sign(j2,mone2) /= j2) call abort()
+
+ i4 = huge(0_4) ; j4 = -huge(0_4)
+ if (sign(i4, j4) /= j4) call abort()
+ if (sign(j4, i4) /= i4) call abort()
+ if (sign(i4,one4) /= i4 .or. sign(j4,one4) /= i4) call abort()
+ if (sign(i4,mone4) /= j4 .or. sign(j4,mone4) /= j4) call abort()
+
+ i8 = huge(0_8) ; j8 = -huge(0_8)
+ if (sign(i8, j8) /= j8) call abort()
+ if (sign(j8, i8) /= i8) call abort()
+ if (sign(i8,one8) /= i8 .or. sign(j8,one8) /= i8) call abort()
+ if (sign(i8,mone8) /= j8 .or. sign(j8,mone8) /= j8) call abort()
+
+ if (sign(foo(i), 1) /= 1) call abort
+ if (sign(foo(i), -1) /= -2) call abort
+ if (sign(42, foo(i)) /= 42) call abort
+ if (sign(42, -foo(i)) /= -42) call abort
+ if (i /= 5) call abort
+
+ if (sign(bar(), 1) /= 1) call abort
+ if (sign(bar(), -1) /= -2) call abort
+ if (sign(17, bar()) /= 17) call abort
+ if (sign(17, -bar()) /= -17) call abort
+ if (bar() /= 5) call abort
+
+contains
+
+ integer function foo(i)
+ integer :: i
+ foo = i
+ i = i + 1
+ end function
+
+ integer function bar()
+ integer, save :: i = 0
+ i = i + 1
+ bar = i
+ end function
+end