PR tree-optimization/86415 - strlen() not folded for substrings within constant arrays
[official-gcc.git] / gcc / testsuite / gfortran.dg / dim_sum_1.f90
blob6a41ed99d43f3f9790bc3684540491b1d58222d2
1 ! { dg-do run }
2 ! { dg-shouldfail "Dim argument incorrect in SUM intrinsic: is 5, should be between 1 and 2" }
4 program summation
6 integer, parameter :: n1=5, n2=7
7 integer, dimension(1:n1,1:n2) :: arr
8 integer, dimension(1:n1) :: r2
9 integer, dimension(1:n2) :: r1
10 integer :: i,j
11 character(len=80) :: c1, c2
12 character(len=50) :: fmt = '(10I5)'
13 do j=1,n2
14 do i=1,n1
15 arr(i,j) = i+j*10
16 end do
17 end do
19 r1 = sum(arr,dim=1)
20 write (unit=c2, fmt=fmt) r1
21 call print_sum(1,c1)
22 if (c1 /= c2) STOP 1
23 r2 = sum(arr,dim=2)
24 write (unit=c2, fmt=fmt) r2
25 call print_sum(2,c1)
26 if (c1 /= c2) STOP 2
27 call print_sum(5,c1)
29 contains
31 subroutine print_sum(d, c)
32 integer, intent(in) :: d
33 character(len=80), intent(out) :: c
34 write (unit=c, fmt=fmt) sum(arr,dim=d)
35 end subroutine
37 end