diff options
author | Martin Jambor <mjambor@suse.cz> | 2017-07-31 14:43:24 +0200 |
---|---|---|
committer | Martin Jambor <mjambor@suse.cz> | 2017-07-31 14:43:24 +0200 |
commit | b32f12dece884f1fa0f04c643a77105aff6ce8bc (patch) | |
tree | cdab5f10806561fc198f907299b0e55eb5701ef0 /gcc/testsuite/gfortran.dg | |
parent | 166bec868d991fdf71f9a66f994e5977fcab4aa2 (diff) | |
parent | a168a775e93ec31ae743ad282d8e60fa1c116891 (diff) | |
download | gcc-b32f12dece884f1fa0f04c643a77105aff6ce8bc.tar.gz |
Merge branch 'master' into gcngcn
Diffstat (limited to 'gcc/testsuite/gfortran.dg')
19 files changed, 1103 insertions, 2 deletions
diff --git a/gcc/testsuite/gfortran.dg/array_temporaries_4.f90 b/gcc/testsuite/gfortran.dg/array_temporaries_4.f90 new file mode 100644 index 00000000000..d022ce88557 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/array_temporaries_4.f90 @@ -0,0 +1,59 @@ +! { dg-do compile } +! { dg-options "-Warray-temporaries" } +! Tests the fix for PR80164, in which the compiler segfaulted on this +! when using -Warray-temporaries +! +!****************************************************************************** +module global + type :: a + integer :: b + character(8):: c + end type a + interface assignment(=) + module procedure a_to_a, c_to_a, a_to_c + end interface + interface operator(.ne.) + module procedure a_ne_a + end interface + + type(a) :: x(4), y(4) + logical :: l1(4), t = .true., f= .false. +contains +!****************************************************************************** + elemental subroutine a_to_a (m, n) + type(a), intent(in) :: n + type(a), intent(out) :: m + m%b = len ( trim(n%c)) + m%c = n%c + end subroutine a_to_a + elemental subroutine c_to_a (m, n) + character(8), intent(in) :: n + type(a), intent(out) :: m + m%b = m%b + 1 + m%c = n + end subroutine c_to_a + elemental subroutine a_to_c (m, n) + type(a), intent(in) :: n + character(8), intent(out) :: m + m = n%c + end subroutine a_to_c +!****************************************************************************** + elemental logical function a_ne_a (m, n) + type(a), intent(in) :: n + type(a), intent(in) :: m + a_ne_a = (m%b .ne. n%b) .or. (m%c .ne. n%c) + end function a_ne_a +!****************************************************************************** + elemental function foo (m) + type(a) :: foo + type(a), intent(in) :: m + foo%b = 0 + foo%c = m%c + end function foo +end module global +!****************************************************************************** +program test + use global + x = (/a (0, "one"),a (0, "two"),a (0, "three"),a (0, "four")/) ! { dg-warning "Creating array temporary" } + y = x +end program test diff --git a/gcc/testsuite/gfortran.dg/coarray_44.f90 b/gcc/testsuite/gfortran.dg/coarray_44.f90 new file mode 100644 index 00000000000..15fb8c76ce4 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/coarray_44.f90 @@ -0,0 +1,12 @@ +! { dg-do compile } +! { dg-options "-fcoarray=single" } +! +! PR fortran/70071 +! Based on testcases by Gerhard Steinmetz + +program pr70071 + implicit none + integer, allocatable :: z(:)[:,:] + allocate (z(2)[1::2,*]) ! { dg-error "Bad array dimension" } + allocate (z(1::2)[2,*]) ! { dg-error "Bad array specification in ALLOCATE" } +end program pr70071 diff --git a/gcc/testsuite/gfortran.dg/coarray_event_2.f08 b/gcc/testsuite/gfortran.dg/coarray_event_2.f08 new file mode 100644 index 00000000000..20a37f332fb --- /dev/null +++ b/gcc/testsuite/gfortran.dg/coarray_event_2.f08 @@ -0,0 +1,13 @@ +! { dg-do compile } +! { dg-options "-fcoarray=lib -lcaf_single" } + +! Check that pr79866 is really fixed. + + use iso_fortran_env + type(event_type) :: x ! { dg-error "of type EVENT_TYPE or with subcomponent of type EVENT_TYPE must be a coarray" } + +contains + subroutine exchange + event post (x[1]) ! { dg-error "Syntax error in EVENT POST statement at .1." } + end subroutine +end diff --git a/gcc/testsuite/gfortran.dg/dim_sum_1.f90 b/gcc/testsuite/gfortran.dg/dim_sum_1.f90 new file mode 100644 index 00000000000..b2fb94312d3 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/dim_sum_1.f90 @@ -0,0 +1,37 @@ +! { dg-do run } +! { dg-shouldfail "Dim argument incorrect in SUM intrinsic: is 5, should be between 1 and 2" } + +program summation + + integer, parameter :: n1=5, n2=7 + integer, dimension(1:n1,1:n2) :: arr + integer, dimension(1:n1) :: r2 + integer, dimension(1:n2) :: r1 + integer :: i,j + character(len=80) :: c1, c2 + character(len=50) :: fmt = '(10I5)' + do j=1,n2 + do i=1,n1 + arr(i,j) = i+j*10 + end do + end do + + r1 = sum(arr,dim=1) + write (unit=c2, fmt=fmt) r1 + call print_sum(1,c1) + if (c1 /= c2) call abort + r2 = sum(arr,dim=2) + write (unit=c2, fmt=fmt) r2 + call print_sum(2,c1) + if (c1 /= c2) call abort + call print_sum(5,c1) + +contains + + subroutine print_sum(d, c) + integer, intent(in) :: d + character(len=80), intent(out) :: c + write (unit=c, fmt=fmt) sum(arr,dim=d) + end subroutine + +end diff --git a/gcc/testsuite/gfortran.dg/dim_sum_2.f90 b/gcc/testsuite/gfortran.dg/dim_sum_2.f90 new file mode 100644 index 00000000000..6290444a81d --- /dev/null +++ b/gcc/testsuite/gfortran.dg/dim_sum_2.f90 @@ -0,0 +1,37 @@ +! { dg-do run } +! { dg-shouldfail "Dim argument incorrect in SUM intrinsic: is 5, should be between 1 and 2" } + +program summation + + integer, parameter :: n1=5, n2=7 + integer, dimension(1:n1,1:n2) :: arr + integer, dimension(1:n1) :: r2 + integer, dimension(1:n2) :: r1 + integer :: i,j + character(len=80) :: c1, c2 + character(len=50) :: fmt = '(10I5)' + do j=1,n2 + do i=1,n1 + arr(i,j) = i+j*10 + end do + end do + + r1 = sum(arr,dim=1,mask=arr>23) + write (unit=c2, fmt=fmt) r1 + call print_sum(1,c1) + if (c1 /= c2) call abort + r2 = sum(arr,dim=2,mask=arr>23) + write (unit=c2, fmt=fmt) r2 + call print_sum(2,c1) + if (c1 /= c2) call abort + call print_sum(5,c1) + +contains + + subroutine print_sum(d, c) + integer, intent(in) :: d + character(len=80), intent(out) :: c + write (unit=c, fmt=fmt) sum(arr,dim=d,mask=arr>23) + end subroutine + +end diff --git a/gcc/testsuite/gfortran.dg/dim_sum_3.f90 b/gcc/testsuite/gfortran.dg/dim_sum_3.f90 new file mode 100644 index 00000000000..2661b3700fd --- /dev/null +++ b/gcc/testsuite/gfortran.dg/dim_sum_3.f90 @@ -0,0 +1,37 @@ +! { dg-do run } +! { dg-shouldfail "Dim argument incorrect in SUM intrinsic: is 5, should be between 1 and 2" } + +program summation + + integer, parameter :: n1=5, n2=7 + integer, dimension(1:n1,1:n2) :: arr + integer, dimension(1:n1) :: r2 + integer, dimension(1:n2) :: r1 + integer :: i,j + character(len=80) :: c1, c2 + character(len=50) :: fmt = '(10I5)' + do j=1,n2 + do i=1,n1 + arr(i,j) = i+j*10 + end do + end do + + r1 = sum(arr,dim=1,mask=.true.) + write (unit=c2, fmt=fmt) r1 + call print_sum(1,c1) + if (c1 /= c2) call abort + r2 = sum(arr,dim=2,mask=.true.) + write (unit=c2, fmt=fmt) r2 + call print_sum(2,c1) + if (c1 /= c2) call abort + call print_sum(5,c1) + +contains + + subroutine print_sum(d, c) + integer, intent(in) :: d + character(len=80), intent(out) :: c + write (unit=c, fmt=fmt) sum(arr,dim=d,mask=.true.) + end subroutine + +end diff --git a/gcc/testsuite/gfortran.dg/eoshift_3.f90 b/gcc/testsuite/gfortran.dg/eoshift_3.f90 new file mode 100644 index 00000000000..d1087aa8654 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/eoshift_3.f90 @@ -0,0 +1,178 @@ +! { dg-do run } +! Check that eoshift works for three-dimensional arrays. +module x + implicit none +contains + subroutine eoshift_0 (array, shift, boundary, dim, res) + real, dimension(:,:,:), intent(in) :: array + real, dimension(:,:,:), intent(out) :: res + integer, value :: shift + real, optional, intent(in) :: boundary + integer, optional, intent(in) :: dim + integer :: s1, s2, s3 + integer :: n1, n2, n3 + + real :: b + integer :: d + if (present(boundary)) then + b = boundary + else + b = 0.0 + end if + + if (present(dim)) then + d = dim + else + d = 1 + end if + + n1 = size(array,1) + n2 = size(array,2) + n3 = size(array,3) + + select case(dim) + case(1) + if (shift > 0) then + shift = min(shift, n1) + do s3=1,n3 + do s2=1,n2 + do s1= 1, n1 - shift + res(s1,s2,s3) = array(s1+shift,s2,s3) + end do + do s1 = n1 - shift + 1,n1 + res(s1,s2,s3) = b + end do + end do + end do + + else + shift = max(shift, -n1) + do s3=1,n3 + do s2=1,n2 + do s1=1,-shift + res(s1,s2,s3) = b + end do + do s1= 1-shift,n1 + res(s1,s2,s3) = array(s1+shift,s2,s3) + end do + end do + end do + end if + + case(2) + if (shift > 0) then + shift = min(shift, n2) + do s3=1,n3 + do s2=1, n2 - shift + do s1=1,n1 + res(s1,s2,s3) = array(s1,s2+shift,s3) + end do + end do + do s2=n2 - shift + 1, n2 + do s1=1,n1 + res(s1,s2,s3) = b + end do + end do + end do + else + shift = max(shift, -n2) + do s3=1,n3 + do s2=1,-shift + do s1=1,n1 + res(s1,s2,s3) = b + end do + end do + do s2=1-shift,n2 + do s1=1,n1 + res(s1,s2,s3) = array(s1,s2+shift,s3) + end do + end do + end do + end if + + case(3) + if (shift > 0) then + shift = min(shift, n3) + do s3=1,n3 - shift + do s2=1, n2 + do s1=1,n1 + res(s1,s2,s3) = array(s1,s2,s3+shift) + end do + end do + end do + do s3=n3 - shift + 1, n3 + do s2=1, n2 + do s1=1,n1 + res(s1,s2,s3) = b + end do + end do + end do + else + shift = max(shift, -n3) + do s3=1,-shift + do s2=1,n2 + do s1=1,n1 + res(s1,s2,s3) = b + end do + end do + end do + do s3=1-shift,n3 + do s2=1,n2 + do s1=1,n1 + res(s1,s2,s3) = array(s1,s2,s3+shift) + end do + end do + end do + end if + + case default + stop "Illegal dim" + end select + end subroutine eoshift_0 +end module x + +program main + use x + implicit none + integer, parameter :: n1=2,n2=4,n3=2 + real, dimension(n1,n2,n3) :: a,b,c + integer :: dim, shift, shift_lim + call random_number(a) + + do dim=1,3 + if (dim == 1) then + shift_lim = n1 + 1 + else if (dim == 2) then + shift_lim = n2 + 1 + else + shift_lim = n3 + 1 + end if + do shift=-shift_lim, shift_lim + b = eoshift(a,shift,dim=dim) + call eoshift_0 (a, shift=shift, dim=dim, res=c) + if (any (b /= c)) then + print *,"dim = ", dim, "shift = ", shift + call abort + end if + end do + end do + call random_number(b) + c = b + + do dim=1,3 + if (dim == 1) then + shift_lim = n1/2 + 1 + else if (dim == 2) then + shift_lim = n2/2 + 1 + else + shift_lim = n3/2 + 1 + end if + + do shift=-shift_lim, shift_lim + b(1:n1:2,:,:) = eoshift(a(1:n1/2,:,:),shift,dim=dim) + call eoshift_0 (a(1:n1/2,:,:), shift=shift, dim=dim, res=c(1:n1:2,:,:)) + if (any (b /= c)) call abort + end do + end do + +end program main diff --git a/gcc/testsuite/gfortran.dg/eoshift_4.f90 b/gcc/testsuite/gfortran.dg/eoshift_4.f90 new file mode 100644 index 00000000000..6d1a28a8479 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/eoshift_4.f90 @@ -0,0 +1,187 @@ +! { dg-do run } +! Check that eoshift works for three-dimensional arrays. +module x + implicit none +contains + subroutine eoshift_2 (array, shift, boundary, dim, res) + real, dimension(:,:,:), intent(in) :: array + real, dimension(:,:,:), intent(out) :: res + integer, value :: shift + real, optional, dimension(:,:), intent(in) :: boundary + integer, optional, intent(in) :: dim + integer :: s1, s2, s3 + integer :: n1, n2, n3 + + real :: b + integer :: d + + if (present(dim)) then + d = dim + else + d = 1 + end if + + n1 = size(array,1) + n2 = size(array,2) + n3 = size(array,3) + + select case(dim) + case(1) + if (shift > 0) then + shift = min(shift, n1) + do s3=1,n3 + do s2=1,n2 + b = boundary(s2,s3) + do s1= 1, n1 - shift + res(s1,s2,s3) = array(s1+shift,s2,s3) + end do + do s1 = n1 - shift + 1,n1 + res(s1,s2,s3) = b + end do + end do + end do + + else + shift = max(shift, -n1) + do s3=1,n3 + do s2=1,n2 + b = boundary(s2,s3) + do s1=1,-shift + res(s1,s2,s3) = b + end do + do s1= 1-shift,n1 + res(s1,s2,s3) = array(s1+shift,s2,s3) + end do + end do + end do + end if + + case(2) + if (shift > 0) then + shift = min(shift, n2) + do s3=1,n3 + do s2=1, n2 - shift + do s1=1,n1 + res(s1,s2,s3) = array(s1,s2+shift,s3) + end do + end do + do s2=n2 - shift + 1, n2 + do s1=1,n1 + b = boundary(s1,s3) + res(s1,s2,s3) = b + end do + end do + end do + else + shift = max(shift, -n2) + do s3=1,n3 + do s2=1,-shift + do s1=1,n1 + b = boundary(s1,s3) + res(s1,s2,s3) = b + end do + end do + do s2=1-shift,n2 + do s1=1,n1 + res(s1,s2,s3) = array(s1,s2+shift,s3) + end do + end do + end do + end if + + case(3) + if (shift > 0) then + shift = min(shift, n3) + do s3=1,n3 - shift + do s2=1, n2 + do s1=1,n1 + res(s1,s2,s3) = array(s1,s2,s3+shift) + end do + end do + end do + do s3=n3 - shift + 1, n3 + do s2=1, n2 + do s1=1,n1 + b = boundary(s1,s2) + res(s1,s2,s3) = b + end do + end do + end do + else + shift = max(shift, -n3) + do s3=1,-shift + do s2=1,n2 + do s1=1,n1 + b = boundary(s1,s2) + res(s1,s2,s3) = b + end do + end do + end do + do s3=1-shift,n3 + do s2=1,n2 + do s1=1,n1 + res(s1,s2,s3) = array(s1,s2,s3+shift) + end do + end do + end do + end if + + case default + stop "Illegal dim" + end select + end subroutine eoshift_2 +end module x + +program main + use x + implicit none + integer, parameter :: n1=20,n2=30,n3=40 + real, dimension(n1,n2,n3) :: a,b,c + real, dimension(2*n1,n2,n3) :: a2,c2 + integer :: dim, shift, shift_lim + real, dimension(n2,n3), target :: b1 + real, dimension(n1,n3), target :: b2 + real, dimension(n1,n2), target :: b3 + real, dimension(:,:), pointer :: bp + + call random_number(a) + call random_number (b1) + call random_number (b2) + call random_number (b3) + do dim=1,3 + if (dim == 1) then + shift_lim = n1 + 1 + bp => b1 + else if (dim == 2) then + shift_lim = n2 + 1 + bp => b2 + else + shift_lim = n3 + 1 + bp => b3 + end if + do shift=-shift_lim, shift_lim + b = eoshift(a,shift,dim=dim, boundary=bp) + call eoshift_2 (a, shift=shift, dim=dim, boundary=bp, res=c) + if (any (b /= c)) then + print *,"dim = ", dim, "shift = ", shift + print *,b + print *,c + call abort + end if + a2 = 42. + a2(1:2*n1:2,:,:) = a + b = eoshift(a2(1:2*n1:2,:,:), shift, dim=dim, boundary=bp) + if (any (b /= c)) then + call abort + end if + c2 = 43. + c2(1:2*n1:2,:,:) = eoshift(a,shift,dim=dim, boundary=bp) + if (any(c2(1:2*n1:2,:,:) /= c)) then + call abort + end if + if (any(c2(2:2*n1:2,:,:) /= 43)) then + call abort + end if + end do + end do +end program main diff --git a/gcc/testsuite/gfortran.dg/eoshift_5.f90 b/gcc/testsuite/gfortran.dg/eoshift_5.f90 new file mode 100644 index 00000000000..a8c2494ad76 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/eoshift_5.f90 @@ -0,0 +1,182 @@ +! { dg-do run } +! Check that eoshift works for three-dimensional arrays. +module x + implicit none +contains + subroutine eoshift_1 (array, shift, boundary, dim, res) + real, dimension(:,:,:), intent(in) :: array + real, dimension(:,:,:), intent(out) :: res + integer, dimension(:,:), intent(in) :: shift + real, optional, intent(in) :: boundary + integer, optional, intent(in) :: dim + integer :: s1, s2, s3 + integer :: n1, n2, n3 + integer :: sh + real :: b + integer :: d + + if (present(boundary)) then + b = boundary + else + b = 0.0 + end if + + if (present(dim)) then + d = dim + else + d = 1 + end if + + n1 = size(array,1) + n2 = size(array,2) + n3 = size(array,3) + + select case(dim) + case(1) + do s3=1,n3 + do s2=1,n2 + sh = shift(s2,s3) + if (sh > 0) then + sh = min(sh, n1) + do s1= 1, n1 - sh + res(s1,s2,s3) = array(s1+sh,s2,s3) + end do + do s1 = n1 - sh + 1,n1 + res(s1,s2,s3) = b + end do + else + sh = max(sh, -n1) + do s1=1,-sh + res(s1,s2,s3) = b + end do + do s1= 1-sh,n1 + res(s1,s2,s3) = array(s1+sh,s2,s3) + end do + end if + end do + end do + case(2) + do s3=1,n3 + do s1=1,n1 + sh = shift(s1,s3) + if (sh > 0) then + sh = min (sh, n2) + do s2=1, n2 - sh + res(s1,s2,s3) = array(s1,s2+sh,s3) + end do + do s2=n2 - sh + 1, n2 + res(s1,s2,s3) = b + end do + else + sh = max(sh, -n2) + do s2=1,-sh + res(s1,s2,s3) = b + end do + do s2=1-sh,n2 + res(s1,s2,s3) = array(s1,s2+sh,s3) + end do + end if + end do + end do + + case(3) + do s2=1, n2 + do s1=1,n1 + sh = shift(s1, s2) + if (sh > 0) then + sh = min(sh, n3) + do s3=1,n3 - sh + res(s1,s2,s3) = array(s1,s2,s3+sh) + end do + do s3=n3 - sh + 1, n3 + res(s1,s2,s3) = b + end do + else + sh = max(sh, -n3) + do s3=1,-sh + res(s1,s2,s3) = b + end do + do s3=1-sh,n3 + res(s1,s2,s3) = array(s1,s2,s3+sh) + end do + end if + end do + end do + + case default + stop "Illegal dim" + end select + end subroutine eoshift_1 + subroutine fill_shift(x, n) + integer, intent(out), dimension(:,:) :: x + integer, intent(in) :: n + integer :: n1, n2, s1, s2 + integer :: v + v = -n - 1 + n1 = size(x,1) + n2 = size(x,2) + do s2=1,n2 + do s1=1,n1 + x(s1,s2) = v + v = v + 1 + if (v > n + 1) v = -n - 1 + end do + end do + end subroutine fill_shift +end module x + +program main + use x + implicit none + integer, parameter :: n1=20,n2=30,n3=40 + real, dimension(n1,n2,n3) :: a,b,c + real, dimension(2*n1,n2,n3) :: a2, c2 + integer :: dim + integer, dimension(n2,n3), target :: sh1 + integer, dimension(n1,n3), target :: sh2 + integer, dimension(n1,n2), target :: sh3 + real, dimension(n2,n3), target :: b1 + real, dimension(n1,n3), target :: b2 + real, dimension(n1,n2), target :: b3 + + integer, dimension(:,:), pointer :: sp + real, dimension(:,:), pointer :: bp + + call random_number(a) + call fill_shift(sh1, n1) + call fill_shift(sh2, n2) + call fill_shift(sh3, n3) + + do dim=1,3 + if (dim == 1) then + sp => sh1 + else if (dim == 2) then + sp => sh2 + else + sp => sh3 + end if + b = eoshift(a,shift=sp,dim=dim,boundary=-0.5) + call eoshift_1 (a, shift=sp, dim=dim, boundary=-0.5,res=c) + if (any (b /= c)) then + print *,"dim = ", dim + print *,"sp = ", sp + print '(99F8.4)',b + print '(99F8.4)',c + call abort + end if + a2 = 42. + a2(1:2*n1:2,:,:) = a + b = eoshift(a2(1:2*n1:2,:,:), shift=sp, dim=dim, boundary=-0.5) + if (any(b /= c)) then + call abort + end if + c2 = 43. + c2(1:2*n1:2,:,:) = eoshift(a, shift=sp, dim=dim, boundary=-0.5) + if (any(c2(1:2*n1:2,:,:) /= c)) then + call abort + end if + if (any(c2(2:2*n1:2,:,:) /= 43.)) then + call abort + end if + end do +end program main diff --git a/gcc/testsuite/gfortran.dg/eoshift_6.f90 b/gcc/testsuite/gfortran.dg/eoshift_6.f90 new file mode 100644 index 00000000000..f3f833cc941 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/eoshift_6.f90 @@ -0,0 +1,181 @@ +! { dg-do run } +! Check that eoshift works for three-dimensional arrays. +module x + implicit none +contains + subroutine eoshift_3 (array, shift, boundary, dim, res) + real, dimension(:,:,:), intent(in) :: array + real, dimension(:,:,:), intent(out) :: res + integer, dimension(:,:), intent(in) :: shift + real, optional, dimension(:,:), intent(in) :: boundary + integer, optional, intent(in) :: dim + integer :: s1, s2, s3 + integer :: n1, n2, n3 + integer :: sh + real :: b + integer :: d + + if (present(dim)) then + d = dim + else + d = 1 + end if + + n1 = size(array,1) + n2 = size(array,2) + n3 = size(array,3) + + select case(dim) + case(1) + do s3=1,n3 + do s2=1,n2 + sh = shift(s2,s3) + b = boundary(s2,s3) + if (sh > 0) then + sh = min(sh, n1) + do s1= 1, n1 - sh + res(s1,s2,s3) = array(s1+sh,s2,s3) + end do + do s1 = n1 - sh + 1,n1 + res(s1,s2,s3) = b + end do + else + sh = max(sh, -n1) + do s1=1,-sh + res(s1,s2,s3) = b + end do + do s1= 1-sh,n1 + res(s1,s2,s3) = array(s1+sh,s2,s3) + end do + end if + end do + end do + case(2) + do s3=1,n3 + do s1=1,n1 + sh = shift(s1,s3) + b = boundary(s1,s3) + if (sh > 0) then + sh = min (sh, n2) + do s2=1, n2 - sh + res(s1,s2,s3) = array(s1,s2+sh,s3) + end do + do s2=n2 - sh + 1, n2 + res(s1,s2,s3) = b + end do + else + sh = max(sh, -n2) + do s2=1,-sh + res(s1,s2,s3) = b + end do + do s2=1-sh,n2 + res(s1,s2,s3) = array(s1,s2+sh,s3) + end do + end if + end do + end do + + case(3) + do s2=1, n2 + do s1=1,n1 + sh = shift(s1, s2) + b = boundary(s1, s2) + if (sh > 0) then + sh = min(sh, n3) + do s3=1,n3 - sh + res(s1,s2,s3) = array(s1,s2,s3+sh) + end do + do s3=n3 - sh + 1, n3 + res(s1,s2,s3) = b + end do + else + sh = max(sh, -n3) + do s3=1,-sh + res(s1,s2,s3) = b + end do + do s3=1-sh,n3 + res(s1,s2,s3) = array(s1,s2,s3+sh) + end do + end if + end do + end do + + case default + stop "Illegal dim" + end select + end subroutine eoshift_3 + subroutine fill_shift(x, n) + integer, intent(out), dimension(:,:) :: x + integer, intent(in) :: n + integer :: n1, n2, s1, s2 + integer :: v + v = -n - 1 + n1 = size(x,1) + n2 = size(x,2) + do s2=1,n2 + do s1=1,n1 + x(s1,s2) = v + v = v + 1 + if (v > n + 1) v = -n - 1 + end do + end do + end subroutine fill_shift +end module x + +program main + use x + implicit none + integer, parameter :: n1=10,n2=30,n3=40 + real, dimension(n1,n2,n3) :: a,b,c + real, dimension(2*n1,n2,n3) :: a2, c2 + integer :: dim + integer, dimension(n2,n3), target :: sh1 + integer, dimension(n1,n3), target :: sh2 + integer, dimension(n1,n2), target :: sh3 + real, dimension(n2,n3), target :: b1 + real, dimension(n1,n3), target :: b2 + real, dimension(n1,n2), target :: b3 + + integer, dimension(:,:), pointer :: sp + real, dimension(:,:), pointer :: bp + + call random_number(a) + call random_number(b1) + call random_number(b2) + call random_number(b3) + call fill_shift(sh1, n1) + call fill_shift(sh2, n2) + call fill_shift(sh3, n3) + + do dim=1,3 + if (dim == 1) then + sp => sh1 + bp => b1 + else if (dim == 2) then + sp => sh2 + bp => b2 + else + sp => sh3 + bp => b3 + end if + b = eoshift(a,shift=sp,dim=dim,boundary=bp) + call eoshift_3 (a, shift=sp, dim=dim, boundary=bp,res=c) + if (any (b /= c)) then + call abort + end if + a2 = 42. + a2(1:2*n1:2,:,:) = a + b = eoshift(a2(1:2*n1:2,:,:), shift=sp, dim=dim, boundary=bp) + if (any(b /= c)) then + call abort + end if + c2 = 43. + c2(1:2*n1:2,:,:) = eoshift(a, shift=sp, dim=dim, boundary=bp) + if (any(c2(1:2*n1:2,:,:) /= c)) then + call abort + end if + if (any(c2(2:2*n1:2,:,:) /= 43.)) then + call abort + end if + end do +end program main diff --git a/gcc/testsuite/gfortran.dg/goacc/pr77765.f90 b/gcc/testsuite/gfortran.dg/goacc/pr77765.f90 new file mode 100644 index 00000000000..3819cf70c04 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/goacc/pr77765.f90 @@ -0,0 +1,19 @@ +! Test the presence of an ACC ROUTINE directive inside a function +! containg an error. + +! { dg-do compile } + +module m +contains + recursive function f(x) + end function f + recursive function f(x) + !$acc routine (f) + end function f +end module m + +! { dg-error "Procedure 'f' at .1. is already defined" "" { target *-*-* } 8 } +! { dg-error "Duplicate RECURSIVE attribute specified" "" { target *-*-* } 8 } +! { dg-error ".1." "" { target *-*-* } 10 } +! { dg-error "Unexpected ..ACC ROUTINE" "" { target *-*-* } 11 } +! { dg-error "Expecting END MODULE statement" "" { target *-*-* } 12 } diff --git a/gcc/testsuite/gfortran.dg/namelist_3.f90 b/gcc/testsuite/gfortran.dg/namelist_3.f90 index f37946d53c9..3f20ea400c4 100644 --- a/gcc/testsuite/gfortran.dg/namelist_3.f90 +++ b/gcc/testsuite/gfortran.dg/namelist_3.f90 @@ -4,5 +4,5 @@ program namelist_3 integer,pointer :: x allocate (x) - namelist /n/ x ! { dg-error "NAMELIST attribute with POINTER attribute" } + namelist /n/ x ! { dg-error "NAMELIST attribute conflicts with POINTER attribute" } end program namelist_3 diff --git a/gcc/testsuite/gfortran.dg/pointer_intent_2.f90 b/gcc/testsuite/gfortran.dg/pointer_intent_2.f90 index 692570339a3..02f91b80495 100644 --- a/gcc/testsuite/gfortran.dg/pointer_intent_2.f90 +++ b/gcc/testsuite/gfortran.dg/pointer_intent_2.f90 @@ -14,6 +14,6 @@ program test call a(p) ! { dg-error "Type mismatch in argument" } contains subroutine a(p)! { dg-error "has no IMPLICIT type" } - integer, pointer,intent(in) :: p ! { dg-error "POINTER attribute with INTENT attribute" } + integer, pointer,intent(in) :: p ! { dg-error "POINTER attribute conflicts with INTENT attribute" } end subroutine end program diff --git a/gcc/testsuite/gfortran.dg/pr81175.f b/gcc/testsuite/gfortran.dg/pr81175.f new file mode 100644 index 00000000000..130ba9c1632 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr81175.f @@ -0,0 +1,23 @@ +! { dg-do compile } +! { dg-options "-Ofast -fwrapv" } +! { dg-additional-options "-march=broadwell" { target x86_64-*-* i?86-*-* } } + SUBROUTINE ECPDRA(IC4C,FP,FQ,G) + IMPLICIT DOUBLE PRECISION (A-H,O-Z) + DIMENSION FP(*),FQ(*),G(*) + DIMENSION CKLU(23,12,12) +! + DO 240 I=IAMIN,IAMAX + DO 240 J=JAMIN,MMAX + DO 230 K=1,NPNP + DO 230 L=1,K + DO 230 MU=1,2*L-1 + CKLTEM= CKLU(MU,L,K) + IF(IC4C.LE.0) THEN + IF(ABS(CKLTEM).GT.TOL) SUM= SUM+FP(N)*CKLTEM + ELSE + IF(ABS(CKLTEM).GT.TOL) SUM= SUM+FQ(N)*CKLTEM + END IF + 230 N= N+1 + G(NN)= G(NN)+DUMJ*SUM + 240 NN= NN+1 + END diff --git a/gcc/testsuite/gfortran.dg/pr81464.f90 b/gcc/testsuite/gfortran.dg/pr81464.f90 new file mode 100644 index 00000000000..425cae9470c --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr81464.f90 @@ -0,0 +1,19 @@ +! { dg-do compile } +! { dg-options "--param parloops-chunk-size=2 -ftree-parallelize-loops=2 -O1" } + +program main + implicit none + real, dimension(:,:),allocatable :: a, b, c + real :: sm + + allocate (a(2,2), b(2,2), c(2,2)) + + call random_number(a) + call random_number(b) + + c = matmul(a,b) + sm = sum(c) + + deallocate(a,b,c) + +end program main diff --git a/gcc/testsuite/gfortran.dg/pr81529.f90 b/gcc/testsuite/gfortran.dg/pr81529.f90 new file mode 100644 index 00000000000..92e3d48e727 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr81529.f90 @@ -0,0 +1,32 @@ +! { dg-do compile } +! { dg-options "-std=gnu -fno-tree-scev-cprop -Ofast" } + +subroutine CalcCgr(C,rmax,ordgr_max) + integer, intent(in) :: rmax,ordgr_max + double complex :: Zadj(2,2), Zadj2(2,2) + double complex, intent(out) :: C(0:rmax,0:rmax,0:rmax) + double complex, allocatable :: Cexpgr(:,:,:,:) + double complex :: Caux + integer :: rmaxB,rmaxExp,r,n0,n1,n2,k,l,i,j,m,n,nn + + rmaxB = 2*rmax + rmaxExp = rmaxB + allocate(Cexpgr(0:rmaxExp/2,0:rmaxExp,0:rmaxExp,0:ordgr_max)) + + rloop: do r=0,rmaxExp/2 + do n0=r,1,-1 + do nn=r-n0,0,-1 + do i=1,2 + Caux = Caux - Zadj(i,l) + end do + Cexpgr(n0,0,0,0) = Caux/(2*(nn+1)) + end do + end do + do n1=0,r + n2 = r-n1 + if (r.le.rmax) then + C(0,n1,n2) = Cexpgr(0,n1,n2,0) + end if + end do + end do rloop +end subroutine CalcCgr diff --git a/gcc/testsuite/gfortran.dg/realloc_on_assign_28.f90 b/gcc/testsuite/gfortran.dg/realloc_on_assign_28.f90 new file mode 100644 index 00000000000..2e338e470fd --- /dev/null +++ b/gcc/testsuite/gfortran.dg/realloc_on_assign_28.f90 @@ -0,0 +1,40 @@ +! { dg-do run } +! +! PR fortran/66102 +! +! Contributed by Vladimir Fuka <vladimir.fuka@gmail.com> +! + type t + integer,allocatable :: i + end type + + type(t) :: e + type(t), allocatable, dimension(:) :: a, b + integer :: chksum = 0 + + do i=1,3 ! Was 100 in original + e%i = i + chksum = chksum + i + if (.not.allocated(a)) then + a = [e] + b = first_arg([e], [e]) + else + call foo + end if + end do + + if (sum ([(a(i)%i, i=1,size(a))]) .ne. chksum) call abort + if (any([(a(i)%i, i=1,size(a))] /= [(i, i=1,size(a))])) call abort + if (size(a) /= size(b)) call abort + if (any([(b(i)%i, i=1,size(b))] /= [(i, i=1,size(b))])) call abort +contains + subroutine foo + b = first_arg([b, e], [a, e]) + a = [a, e] + end subroutine + elemental function first_arg(arg1, arg2) + type(t), intent(in) :: arg1, arg2 + type(t) :: first_arg + first_arg = arg1 + end function first_arg +end diff --git a/gcc/testsuite/gfortran.dg/vect/pr60510.f b/gcc/testsuite/gfortran.dg/vect/pr60510.f new file mode 100644 index 00000000000..5e2c085d761 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/vect/pr60510.f @@ -0,0 +1,30 @@ +! { dg-do run } +! { dg-require-effective-target vect_double } +! { dg-additional-options "-fno-inline -ffast-math" } + subroutine foo(a,x,y,n) + implicit none + integer n,i + + real*8 y(n),x(n),a + + do i=1,n + a=a+x(i)*y(i)+x(i) + enddo + + return + end + + program test + real*8 x(1024),y(1024),a + do i=1,1024 + x(i) = i + y(i) = i+1 + enddo + call foo(a,x,y,1024) + if (a.ne.359488000.0) call abort() + end +! If there's no longer a reduction chain detected this doesn't test what +! it was supposed to test, vectorizing a reduction chain w/o SLP. +! { dg-final { scan-tree-dump "reduction chain" "vect" } } +! We should vectorize the reduction in foo and the induction in test. +! { dg-final { scan-tree-dump-times "vectorized 1 loops" 2 "vect" } } diff --git a/gcc/testsuite/gfortran.dg/vect/pr61171.f b/gcc/testsuite/gfortran.dg/vect/pr61171.f new file mode 100644 index 00000000000..f94b8f31283 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/vect/pr61171.f @@ -0,0 +1,15 @@ +! { dg-do compile } +! { dg-additional-options "-Ofast" } + SUBROUTINE GAUBON(NV,PTS,PP) + IMPLICIT DOUBLE PRECISION(A-H,O-Z) + PARAMETER (MXSP=250) + DIMENSION PTS(3,10),PP(3) + COMMON /PCMPLY/ XE(MXSP),YE(MXSP),ZE(MXSP) + DATA PI/3.141592653589793D+00/ + DATA ZERO/0.0D+00/ + DO I = 1, NV + PP(1) = PP(1) + (PTS(1,I)-XE(NS)) + PP(2) = PP(2) + (PTS(2,I)-YE(NS)) + PP(3) = PP(3) + (PTS(3,I)-ZE(NS)) + ENDDO + END |