Debian Codegraph @

gcc/testsuite/gfortran.dg/allocate_with_source_32.f90

raw
1 ! { dg-do run }
2 !
3 ! PR fortran/83865
4 !
5 ! Test ALLOCATE with SOURCE= of deferred length character, where
6 ! the source-expression is an array of character with length 0.
7
8 program p
9 implicit none
10 character(:), allocatable :: z(:)
11 character(1) :: cc(4) = ""
12 allocate (z, source=[''])
13 if (len (z) /= 0 .or. size (z) /= 1) stop 1
14 deallocate (z)
15 allocate (z, source=['',''])
16 if (len (z) /= 0 .or. size (z) /= 2) stop 2
17 deallocate (z)
18 allocate (z, source=[ character(0) :: 'a','b','c'])
19 if (len (z) /= 0 .or. size (z) /= 3) stop 3
20 deallocate (z)
21 allocate (z, source=[ character(0) :: cc ])
22 if (len (z) /= 0 .or. size (z) /= 4) stop 4
23 deallocate (z)
24 associate (x => f())
25 if (len (x) /= 0 .or. size (x) /= 1) stop 5
26 if (x(1) /= '') stop 6
27 end associate
28 contains
29 function f() result(z)
30 character(:), allocatable :: z(:)
31 allocate (z, source=[''])
32 end function f
33 end