Fix compilation failure with C++98 compilers
[official-gcc.git] / gcc / testsuite / gfortran.dg / deferred_character_14.f90
blobc6b7b25ee2fdf6fe44ed23b78b43e0959897dcf8
1 ! { dg-do run }
3 ! Test fix for PR60795 comments #1 and #4
5 ! Contributed by Kergonath <kergonath@me.com>
7 module m
8 contains
9 subroutine allocate_array(s_array)
10 character(:), dimension(:), allocatable, intent(out) :: s_array
12 allocate(character(2) :: s_array(2))
13 s_array = ["ab","cd"]
14 end subroutine
15 end module
17 program stringtest
18 use m
19 character(:), dimension(:), allocatable :: s4
20 character(:), dimension(:), allocatable :: s
21 ! Comment #1
22 allocate(character(1) :: s(10))
23 if (size (s) .ne. 10) STOP 1
24 if (len (s) .ne. 1) STOP 2
25 ! Comment #4
26 call allocate_array(s4)
27 if (size (s4) .ne. 2) STOP 3
28 if (len (s4) .ne. 2) STOP 4
29 if (any (s4 .ne. ["ab", "cd"])) STOP 5
30 end program