gcc/fortran/
[official-gcc.git] / gcc / testsuite / gfortran.dg / allocate_with_source_2.f90
blob8e48b226062285347512c75c8bfa4b8287a72386
1 ! { dg-do run }
2 ! PR 45170
3 ! A variation of a theme for deferred type parameters. The
4 ! substring reference in the source= portion of the allocate
5 ! was not probably resolved. Testcase is a modified version
6 ! of a program due to Hans-Werner Boschmann <boschmann at tp1
7 ! dot physik dot uni-siegen dot de>
9 program helloworld
10 character(:),allocatable::string
11 real::rnd
12 call hello(5, string)
13 if (string /= 'hello' .or. len(string) /= 5) call abort
14 contains
15 subroutine hello (n,string)
16 character(:),allocatable,intent(out)::string
17 integer,intent(in)::n
18 character(20)::helloworld="hello world"
19 allocate(string, source=helloworld(:n))
20 end subroutine hello
21 end program helloworld