Debian Codegraph @

gcc/testsuite/gfortran.dg/allocate_with_source_33.f90

raw
1 ! { dg-do compile }
2 ! { dg-options "-O0" }
3 !
4 ! PR fortran/114019 - allocation with source of deferred character length
5
6 subroutine s
7 implicit none
8 character(1) :: w = "4"
9 character(*), parameter :: str = "123"
10 character(5), pointer :: chr_pointer1
11 character(:), pointer :: chr_pointer2
12 character(:), pointer :: chr_ptr_arr(:)
13 character(5), allocatable :: chr_alloc1
14 character(:), allocatable :: chr_alloc2
15 character(:), allocatable :: chr_all_arr(:)
16 allocate (chr_pointer1, source=w// str//w)
17 allocate (chr_pointer2, source=w// str//w)
18 allocate (chr_ptr_arr, source=w//[str//w])
19 allocate (chr_alloc1, source=w// str//w)
20 allocate (chr_alloc2, source=w// str//w)
21 allocate (chr_all_arr, source=w//[str//w])
22 allocate (chr_pointer2, source=str)
23 allocate (chr_pointer2, source=w)
24 allocate (chr_alloc2, source=str)
25 allocate (chr_alloc2, source=w)
26 allocate (chr_pointer1, mold =w// str//w)
27 allocate (chr_pointer2, mold =w// str//w)
28 allocate (chr_ptr_arr, mold =w//[str//w])
29 allocate (chr_alloc1, mold =w// str//w)
30 allocate (chr_alloc2, mold =w// str//w)
31 allocate (chr_all_arr, mold =w//[str//w])
32 allocate (chr_pointer2, mold =str)
33 allocate (chr_pointer2, mold =w)
34 allocate (chr_alloc2, mold =str)
35 allocate (chr_alloc2, mold =w)
36 end
37
38 subroutine s2
39 implicit none
40 integer, parameter :: ck=4
41 character(kind=ck,len=1) :: w = ck_"4"
42 character(kind=ck,len=*), parameter :: str = ck_"123"
43 character(kind=ck,len=5), pointer :: chr_pointer1
44 character(kind=ck,len=:), pointer :: chr_pointer2
45 character(kind=ck,len=:), pointer :: chr_ptr_arr(:)
46 character(kind=ck,len=5), allocatable :: chr_alloc1
47 character(kind=ck,len=:), allocatable :: chr_alloc2
48 character(kind=ck,len=:), allocatable :: chr_all_arr(:)
49 allocate (chr_pointer1, source=w// str//w)
50 allocate (chr_pointer2, source=w// str//w)
51 allocate (chr_ptr_arr, source=w//[str//w])
52 allocate (chr_alloc1, source=w// str//w)
53 allocate (chr_alloc2, source=w// str//w)
54 allocate (chr_all_arr, source=w//[str//w])
55 allocate (chr_pointer2, source=str)
56 allocate (chr_pointer2, source=w)
57 allocate (chr_alloc2, source=str)
58 allocate (chr_alloc2, source=w)
59 allocate (chr_pointer1, mold =w// str//w)
60 allocate (chr_pointer2, mold =w// str//w)
61 allocate (chr_ptr_arr, mold =w//[str//w])
62 allocate (chr_alloc1, mold =w// str//w)
63 allocate (chr_alloc2, mold =w// str//w)
64 allocate (chr_all_arr, mold =w//[str//w])
65 allocate (chr_pointer2, mold =str)
66 allocate (chr_pointer2, mold =w)
67 allocate (chr_alloc2, mold =str)
68 allocate (chr_alloc2, mold =w)
69 end