aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gfortran.fortran-torture
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/testsuite/gfortran.fortran-torture')
-rw-r--r--gcc/testsuite/gfortran.fortran-torture/execute/in-pack.f9092
-rw-r--r--gcc/testsuite/gfortran.fortran-torture/execute/intrinsic_matmul.f908
-rw-r--r--gcc/testsuite/gfortran.fortran-torture/execute/intrinsic_unpack.f904
3 files changed, 104 insertions, 0 deletions
diff --git a/gcc/testsuite/gfortran.fortran-torture/execute/in-pack.f90 b/gcc/testsuite/gfortran.fortran-torture/execute/in-pack.f90
new file mode 100644
index 00000000000..b9ea2683240
--- /dev/null
+++ b/gcc/testsuite/gfortran.fortran-torture/execute/in-pack.f90
@@ -0,0 +1,92 @@
+! Check in_pack and in_unpack for integer and comlex types, with
+! alignment issues thrown in for good measure.
+
+program main
+ implicit none
+
+ complex(kind=4) :: a4(5),b4(5),aa4(5),bb4(5)
+ real(kind=4) :: r4(100)
+ equivalence(a4(1),r4(1)),(b4(1),r4(12))
+
+ complex(kind=8) :: a8(5),b8(5),aa8(5),bb8(5)
+ real(kind=8) :: r8(100)
+ equivalence(a8(1),r8(1)),(b8(1),r8(12))
+
+ integer(kind=4) :: i4(5),ii4(5)
+ integer(kind=8) :: i8(5),ii8(5)
+
+ integer :: i
+
+ a4 = (/(cmplx(i,-i,kind=4),i=1,5)/)
+ b4 = (/(2*cmplx(i,-i,kind=4),i=1,5)/)
+ call csub4(a4(5:1:-1),b4(5:1:-1),5)
+ aa4 = (/(cmplx(5-i+1,i-5-1,kind=4),i=1,5)/)
+ if (any(aa4 /= a4)) call abort
+ bb4 = (/(2*cmplx(5-i+1,i-5-1,kind=4),i=1,5)/)
+ if (any(bb4 /= b4)) call abort
+
+ a8 = (/(cmplx(i,-i,kind=8),i=1,5)/)
+ b8 = (/(2*cmplx(i,-i,kind=8),i=1,5)/)
+ call csub8(a8(5:1:-1),b8(5:1:-1),5)
+ aa8 = (/(cmplx(5-i+1,i-5-1,kind=8),i=1,5)/)
+ if (any(aa8 /= a8)) call abort
+ bb8 = (/(2*cmplx(5-i+1,i-5-1,kind=8),i=1,5)/)
+ if (any(bb8 /= b8)) call abort
+
+ i4 = (/(i, i=1,5)/)
+ call isub4(i4(5:1:-1),5)
+ ii4 = (/(5-i+1,i=1,5)/)
+ if (any(ii4 /= i4)) call abort
+
+ i8 = (/(i,i=1,5)/)
+ call isub8(i8(5:1:-1),5)
+ ii8 = (/(5-i+1,i=1,5)/)
+ if (any(ii8 /= i8)) call abort
+
+end program main
+
+subroutine csub4(a,b,n)
+ implicit none
+ complex(kind=4), dimension(n) :: a,b
+ complex(kind=4), dimension(n) :: aa, bb
+ integer :: n, i
+ aa = (/(cmplx(n-i+1,i-n-1,kind=4),i=1,n)/)
+ if (any(aa /= a)) call abort
+ bb = (/(2*cmplx(n-i+1,i-n-1,kind=4),i=1,5)/)
+ if (any(bb /= b)) call abort
+ a = (/(cmplx(i,-i,kind=4),i=1,5)/)
+ b = (/(2*cmplx(i,-i,kind=4),i=1,5)/)
+end subroutine csub4
+
+subroutine csub8(a,b,n)
+ implicit none
+ complex(kind=8), dimension(n) :: a,b
+ complex(kind=8), dimension(n) :: aa, bb
+ integer :: n, i
+ aa = (/(cmplx(n-i+1,i-n-1,kind=8),i=1,n)/)
+ if (any(aa /= a)) call abort
+ bb = (/(2*cmplx(n-i+1,i-n-1,kind=8),i=1,5)/)
+ if (any(bb /= b)) call abort
+ a = (/(cmplx(i,-i,kind=8),i=1,5)/)
+ b = (/(2*cmplx(i,-i,kind=8),i=1,5)/)
+end subroutine csub8
+
+subroutine isub4(a,n)
+ implicit none
+ integer(kind=4), dimension(n) :: a
+ integer(kind=4), dimension(n) :: aa
+ integer :: n, i
+ aa = (/(n-i+1,i=1,n)/)
+ if (any(aa /= a)) call abort
+ a = (/(i,i=1,5)/)
+end subroutine isub4
+
+subroutine isub8(a,n)
+ implicit none
+ integer(kind=8), dimension(n) :: a
+ integer(kind=8), dimension(n) :: aa
+ integer :: n, i
+ aa = (/(n-i+1,i=1,n)/)
+ if (any(aa /= a)) call abort
+ a = (/(i,i=1,5)/)
+end subroutine isub8
diff --git a/gcc/testsuite/gfortran.fortran-torture/execute/intrinsic_matmul.f90 b/gcc/testsuite/gfortran.fortran-torture/execute/intrinsic_matmul.f90
index 4b195d267bd..9364f1e1d8b 100644
--- a/gcc/testsuite/gfortran.fortran-torture/execute/intrinsic_matmul.f90
+++ b/gcc/testsuite/gfortran.fortran-torture/execute/intrinsic_matmul.f90
@@ -7,6 +7,8 @@ program intrinsic_matmul
integer, dimension(3) :: y
integer, dimension(2, 2) :: r
integer, dimension(3) :: v
+ real, dimension (2,2) :: aa
+ real, dimension (4,2) :: cc
a = reshape((/1, 2, 2, 3, 3, 4/), (/2, 3/))
b = reshape((/1, 2, 3, 3, 4, 5/), (/3, 2/))
@@ -21,4 +23,10 @@ program intrinsic_matmul
v(1:2) = matmul(a, y)
if (any(v(1:2) .ne. (/14, 20/))) call abort
+
+ aa = reshape((/ 1.0, 1.0, 0.0, 1.0/), shape(aa))
+ cc = 42.
+ cc(1:2,1:2) = matmul(aa, transpose(aa))
+ if (any(cc(1:2,1:2) .ne. reshape((/ 1.0, 1.0, 1.0, 2.0 /), (/2,2/)))) call abort
+ if (any(cc(3:4,1:2) .ne. 42.)) call abort
end program
diff --git a/gcc/testsuite/gfortran.fortran-torture/execute/intrinsic_unpack.f90 b/gcc/testsuite/gfortran.fortran-torture/execute/intrinsic_unpack.f90
index 807aadf136f..88f09c321b4 100644
--- a/gcc/testsuite/gfortran.fortran-torture/execute/intrinsic_unpack.f90
+++ b/gcc/testsuite/gfortran.fortran-torture/execute/intrinsic_unpack.f90
@@ -2,6 +2,7 @@
program intrinsic_unpack
integer, dimension(3, 3) :: a, b
logical, dimension(3, 3) :: mask;
+ character(len=50) line1, line2
integer i
mask = reshape ((/.false.,.true.,.false.,.true.,.false.,.false.,&
@@ -10,6 +11,9 @@ program intrinsic_unpack
b = unpack ((/2, 3, 4/), mask, a)
if (any (b .ne. reshape ((/1, 2, 0, 3, 1, 0, 0, 0, 4/), (/3, 3/)))) &
call abort
+ write (line1,'(10I4)') b
+ write (line2,'(10I4)') unpack((/2, 3, 4/), mask, a)
+ if (line1 .ne. line2) call abort
b = -1
b = unpack ((/2, 3, 4/), mask, 0)
if (any (b .ne. reshape ((/0, 2, 0, 3, 0, 0, 0, 0, 4/), (/3, 3/)))) &