annotate gcc/testsuite/gfortran.dg/char_eoshift_3.f90 @ 144:8f4e72ab4e11

fix segmentation fault caused by nothing next cur_op to end
author Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
date Sun, 23 Dec 2018 21:23:56 +0900
parents 84e7813d76e9
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
111
kono
parents:
diff changeset
1 ! Test eoshift2 for character arrays.
kono
parents:
diff changeset
2 ! { dg-do run }
kono
parents:
diff changeset
3 program main
kono
parents:
diff changeset
4 implicit none
kono
parents:
diff changeset
5 integer, parameter :: n1 = 2, n2 = 5, n3 = 4, slen = 3
kono
parents:
diff changeset
6 character (len = slen), dimension (n1, n2, n3) :: a
kono
parents:
diff changeset
7 character (len = slen), dimension (n1, n3) :: filler
kono
parents:
diff changeset
8 integer (kind = 1) :: shift1 = 4
kono
parents:
diff changeset
9 integer (kind = 2) :: shift2 = 2
kono
parents:
diff changeset
10 integer (kind = 4) :: shift3 = 3
kono
parents:
diff changeset
11 integer (kind = 8) :: shift4 = 1
kono
parents:
diff changeset
12 integer :: i1, i2, i3
kono
parents:
diff changeset
13
kono
parents:
diff changeset
14 filler (1, :) = (/ 'tic', 'tac', 'toe', 'tip' /)
kono
parents:
diff changeset
15 filler (2, :) = (/ 'zzz', 'yyy', 'xxx', 'www' /)
kono
parents:
diff changeset
16
kono
parents:
diff changeset
17 do i3 = 1, n3
kono
parents:
diff changeset
18 do i2 = 1, n2
kono
parents:
diff changeset
19 do i1 = 1, n1
kono
parents:
diff changeset
20 a (i1, i2, i3) = 'ab'(i1:i1) // 'cdefg'(i2:i2) // 'hijk'(i3:i3)
kono
parents:
diff changeset
21 end do
kono
parents:
diff changeset
22 end do
kono
parents:
diff changeset
23 end do
kono
parents:
diff changeset
24
kono
parents:
diff changeset
25 call test (eoshift (a, shift1, filler, 2), int (shift1), .true.)
kono
parents:
diff changeset
26 call test (eoshift (a, shift2, filler, 2), int (shift2), .true.)
kono
parents:
diff changeset
27 call test (eoshift (a, shift3, filler, 2), int (shift3), .true.)
kono
parents:
diff changeset
28 call test (eoshift (a, shift4, filler, 2), int (shift4), .true.)
kono
parents:
diff changeset
29
kono
parents:
diff changeset
30 call test (eoshift (a, shift1, dim = 2), int (shift1), .false.)
kono
parents:
diff changeset
31 call test (eoshift (a, shift2, dim = 2), int (shift2), .false.)
kono
parents:
diff changeset
32 call test (eoshift (a, shift3, dim = 2), int (shift3), .false.)
kono
parents:
diff changeset
33 call test (eoshift (a, shift4, dim = 2), int (shift4), .false.)
kono
parents:
diff changeset
34 contains
kono
parents:
diff changeset
35 subroutine test (b, d2, has_filler)
kono
parents:
diff changeset
36 character (len = slen), dimension (n1, n2, n3) :: b
kono
parents:
diff changeset
37 logical :: has_filler
kono
parents:
diff changeset
38 integer :: d2
kono
parents:
diff changeset
39
kono
parents:
diff changeset
40 do i3 = 1, n3
kono
parents:
diff changeset
41 do i2 = 1, n2
kono
parents:
diff changeset
42 do i1 = 1, n1
kono
parents:
diff changeset
43 if (i2 + d2 .le. n2) then
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
44 if (b (i1, i2, i3) .ne. a (i1, i2 + d2, i3)) STOP 1
111
kono
parents:
diff changeset
45 else if (has_filler) then
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
46 if (b (i1, i2, i3) .ne. filler (i1, i3)) STOP 2
111
kono
parents:
diff changeset
47 else
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
48 if (b (i1, i2, i3) .ne. '') STOP 3
111
kono
parents:
diff changeset
49 end if
kono
parents:
diff changeset
50 end do
kono
parents:
diff changeset
51 end do
kono
parents:
diff changeset
52 end do
kono
parents:
diff changeset
53 end subroutine test
kono
parents:
diff changeset
54 end program main