Debian Codegraph @

gcc/testsuite/gfortran.dg/pr92586.f90

raw
1 ! { dg-do compile }
2 !
3 ! Contributed by Emanuele Pagone <[email protected]>
4 !
5 module foo_m
6 implicit none
7
8 type :: string
9 character(len=:), allocatable :: s
10 end type string
11
12 type :: foo_t
13 type(string), allocatable :: foo_s(:)
14 contains
15 procedure, public :: get_s
16 end type foo_t
17
18 type :: data_t
19 integer :: n_foo_s
20 type(foo_t), allocatable :: foo(:)
21 contains
22 procedure, public :: data_get_foo_s
23 end type data_t
24
25 contains
26
27 function get_s(self)
28 class(foo_t), intent(in) :: self
29 type(string) :: get_s( size(self%foo_s) )
30 get_s = self%foo_s
31 end function get_s
32
33 function data_get_foo_s(self, ith)
34 class(data_t), intent(in) :: self
35 integer, intent(in) :: ith
36 type(string) :: data_get_foo_s(self%n_foo_s)
37
38 data_get_foo_s = self%foo(ith)%get_s() ! The lhs was not dereferenced in a byref call.
39
40 end function data_get_foo_s
41
42 end module foo_m
43
44
45 program bug_stringifor
46 use foo_m
47 implicit none
48
49 type(data_t) :: data
50 type(string), allocatable :: bar(:)
51
52 allocate( data%foo(1) )
53 data%foo(1)%foo_s = [string("alpha"), string("bravo"), string("charlie"), &
54 string("delta"), string("foxtrot")]
55 data%n_foo_s = 5
56
57 bar = data%data_get_foo_s(1)
58
59 print *, "bar = ", bar(1)%s
60
61 end program bug_stringifor