3 ! Contributed by Neil Carlson <neil.n.carlson@gmail.com>
13 type, extends(S
) :: S2
19 class(S
), allocatable
:: x
23 class(*), allocatable
:: x
32 Tobj
= T(S2obj
) ! Failed here
33 select
type (x
=> Tobj
%x
)
35 if ((x
%n
.ne
. 1) .or
. (x
%m
.ne
. 2)) stop 1
41 call pass_it (T(Sobj
))
42 if (c
.ne
. "S ") stop 3
43 call pass_it (T(S2obj
)) ! and here
44 if (c
.ne
. "S2") stop 4
50 subroutine pass_it (foo
)
51 type(T
), intent(in
) :: foo
52 select
type (x
=> foo
%x
)
55 if (x
%n
.ne
. 1) stop 5
58 if ((x
%n
.ne
. 1) .or
. (x
%m
.ne
. 2)) stop 6
64 subroutine check_it (t
, errno
)
67 select
type (x
=> t
%x
)
69 if (x
.ne
. 42) stop errno
71 if (x
.ne
. 42_8) stop errno
73 if (int(x
**2) .ne
. 2) stop errno
74 type is (character(*, kind
=1))
75 if (x
.ne
. "end of tests") stop errno
76 type is (character(*, kind
=4))
77 if ((x
.ne
. 4_
"hello!") .and
. (x
.ne
. 4_
"goodbye")) stop errno
84 ! Test from comment #29 extended by Harald Anlauf to check kinds /= default
85 integer(8), parameter :: i
= 0_8
87 character(7,kind
=4) :: chr4
= 4_
"goodbye"
88 type(tContainer
) :: cont
91 call check_it (cont
, 8)
93 cont
= tContainer(i
+42_8)
94 call check_it (cont
, 9)
96 cont
= tContainer(sqrt (2.0_8
))
97 call check_it (cont
, 10)
99 cont
= tContainer(4_
"hello!")
100 call check_it (cont
, 11)
102 cont
= tContainer(chr4
)
103 call check_it (cont
, 12)
105 cont
= tContainer("end of tests")
106 call check_it (cont
, 13)