3 ! Tests fixes for various pr87477 dependencies
5 ! Contributed by Gerhard Steinmetz <gscfq@t-online.de> except for pr102106:
6 ! which was contributed by Brad Richardson <everythingfunctional@protonmail.com>
10 character(20) :: buffer
27 type :: with_polymorphic_component_t
28 class(sub_class_t
), allocatable
:: sub_obj_
30 associate(obj
=> with_polymorphic_component_t(sub_class_t(42)))
31 if (obj
%sub_obj_
%i
.ne
. 42) stop 1
37 character(:), allocatable
:: c(:)
39 type(t
), allocatable
:: x
41 ! Valid test in comment 1
44 associate (y
=> x
%c(:))
45 if (any (y
.ne
. x
%c
)) stop 2
46 if (any (y
.ne
. ['ab','cd'])) stop 3
50 ! Allocation with source was found to only copy over one of the array elements
52 allocate (x
, source
= t(['ef','gh']))
53 associate (y
=> x
%c(:))
54 if (any (y
.ne
. x
%c
)) stop 4
55 if (any (y
.ne
. ['ef','gh'])) stop 5
61 call s85686([" g'day "," bye!! "])
62 if (trim (buffer
) .ne
. " a g'day a bye!!") stop 6
67 associate (y
=> 'a'//x
)
68 write (buffer
, *) y
! Used to segfault at the write statement.
74 character(:), dimension(:), allocatable
:: d
76 type(t
), allocatable
:: x
77 character(5) :: buffer(3)
78 allocate (x
, source
= t (['ab','cd'])) ! Didn't work
79 write(buffer(1), *) x
%d(2:1:-1) ! Was found to be broken
80 write(buffer(2), *) [x
%d(2:1:-1)] ! Was OK
81 associate (y
=> [x
%d(2:1:-1)])
82 write(buffer(3), *) y
! Bug in comment 7
84 if (any (buffer
.ne
. " cdab")) stop 7
88 character(:), allocatable
:: x(:), z(:)
91 associate (y
=> adjustl(x
)) ! Wrong character length was passed
92 if (any(y
.ne
. ['abc ', 'xyz '])) stop 8
97 character(3) :: a
= 'abc'
98 associate (y
=> spread(trim(a
),1,2) // 'd')
99 if (any (y
.ne
. ['abcd','abcd'])) stop 9
105 character(:), allocatable
:: a(:)
108 x
= t(["abc "]) ! Didn't assign anything
109 ! allocate (x%a(1), source = 'abc') ! Worked OK
111 if (any (y
.ne
. 'abc ')) stop 10
113 if (any (y
.ne
. z
)) stop 11
121 type, extends(t
) :: t2
123 class(t
), allocatable
:: x
126 associate (y
=> (x
)) ! The parentheses triggered an ICE in select type
136 if (i
.ne
. 42) stop 14