2018-05-19 Paul Thomas <pault@gcc.gnu.org>
[official-gcc.git] / gcc / testsuite / gfortran.dg / allocate_assumed_charlen_4.f90
blob1a5539a642b69dfa95ff8a6111a00e8d9a9485bd
1 ! { dg-do run }
3 ! Test the fix for PR82923, in which an ICE occurred because the
4 ! character length from 'getchars' scope was being used in the
5 ! automatic allocation of 'mine'.
7 ! Contributed by "Werner Blokbuster" <werner.blokbuster@gmail.com>
9 module m
10 implicit none
11 contains
12 function getchars(my_len,my_size)
13 integer, intent(in) :: my_len, my_size
14 character(my_len) :: getchars(my_size)
15 getchars = 'A-'
16 end function getchars
18 function getchars2(my_len)
19 integer, intent(in) :: my_len
20 character(my_len) :: getchars2
21 getchars2 = 'B--'
22 end function getchars2
23 end module m
25 program testca
26 use m, only: getchars, getchars2
27 implicit none
28 character(:), allocatable :: mine(:)
29 character(:), allocatable :: mine2
30 integer :: i
32 ! ICE occured at this line:
33 mine = getchars(2,4)
34 if (any (mine .ne. [('A-', i = 1, 4)])) stop 1
36 ! The scalar version was fine and this will keep it so:
37 mine2 = getchars2(3)
38 if (mine2 .ne. 'B--') stop 2
39 end program testca