Debian Codegraph @

gcc/testsuite/gfortran.dg/associate_70.f90

raw
1 ! { dg-do run }
2 ! { dg-options "-Wuninitialized" }
3 !
4 ! Test fix for PR115700 comment 5, in which ‘.tmp1’ is used uninitialized and
5 ! both normal and scalarized array references did not work correctly.
6 ! This testcase checks for correct results and associate_69 for suppression
7 ! of the bogus error.
8 !
9 ! Contributed by Harald Anlauf <[email protected]>
10 !
11 character(4), dimension(3) :: chr = ['abcd', 'efgh', 'ijkl']
12 call mvce (chr)
13 if (any (chr /= ['ABcd', 'EFgh', 'IJkl'])) stop 1
14
15 contains
16 subroutine mvce(x)
17 implicit none
18 character(len=*), dimension(:), intent(inOUT) :: x
19 integer :: i
20 i = len(x)
21
22 associate (tmp1 => x)
23 if (len (tmp1) /= len (x)) stop 2
24 tmp1(2)(3:4) = '12'
25 end associate
26 if (any (x /= ['abcd', 'ef12', 'ijkl'])) stop 3
27
28 associate (tmp2 => x(1:))
29 if (len (tmp2) /= len (x)) stop 4
30 tmp2(2)(1:2) = '34'
31 end associate
32 if (any (x /= ['abcd', '3412', 'ijkl'])) stop 5
33
34 associate (tmp3 => x(1:)(:))
35 if (len (tmp3) /= len (x)) stop 6
36 tmp3(3)(3:4) = '56'
37 end associate
38 if (any (x /= ['abcd', '3412', 'ij56'])) stop 7
39
40 associate (tmp4 => x(:)(1:))
41 if (len (tmp4) /= len (x)) stop 8
42 tmp4(3)(1:2) = '78'
43 end associate
44 if (any (x /= ['abcd', '3412', '7856'])) stop 9
45
46 associate (tmp5 => x(1:)(1:))
47 if (len (tmp5) /= len (x)) stop 10
48 tmp5 = ['abcd', 'efgh', 'ijkl']
49 end associate
50 if (any (x /= ['abcd', 'efgh', 'ijkl'])) stop 11
51
52 associate (tmp6 => x(:)(1:i/2))
53 if (len (tmp6) /= i/2) stop 11
54 if (tmp6(2) /= 'ef') stop 12
55 if (any (tmp6 /= ['ab', 'ef', 'ij'])) stop 13
56 tmp6 = ['AB','EF','IJ']
57 end associate
58
59 end subroutine mvce
60 end