2 ! Test (re)allocation on assignment of scalars
4 ! Contributed by Paul Thomas <pault@gcc.gnu.org>
10 call test_deferred_char1
11 call test_deferred_char4
14 real, allocatable :: x
17 if (x .ne. y) call abort
20 if (x .ne. y) call abort
22 subroutine test_derived
27 type (mytype), allocatable :: t
28 t = mytype (99.0, "abcd")
29 if (t%c .ne. "abcd") call abort
32 character(len = 8), allocatable :: c1
33 character(len = 8) :: c2 = "abcd1234"
35 if (c1 .ne. c2) call abort
38 if (c1 .ne. c2) call abort
41 character(len = 8, kind = 4), allocatable :: c1
42 character(len = 8, kind = 4) :: c2 = 4_"abcd1234"
44 if (c1 .ne. c2) call abort
47 if (c1 .ne. c2) call abort
49 subroutine test_deferred_char1
50 character(:), allocatable :: c
52 if (c .ne. "Hello") call abort
53 if (len(c) .ne. 5) call abort
55 if (c .ne. "Goodbye") call abort
56 if (len(c) .ne. 7) call abort
57 ! Check that the hidden LEN dummy is passed by reference
59 if (c .ne. "Made in test!") print *, c
60 if (len(c) .ne. 13) call abort
62 subroutine test_pass_c1 (carg)
63 character(:), allocatable :: carg
64 if (carg .ne. "Goodbye") call abort
65 if (len(carg) .ne. 7) call abort
66 carg = "Made in test!"
68 subroutine test_deferred_char4
69 character(:, kind = 4), allocatable :: c
71 if (c .ne. 4_"Hello") call abort
72 if (len(c) .ne. 5) call abort
74 if (c .ne. 4_"Goodbye") call abort
75 if (len(c) .ne. 7) call abort
76 ! Check that the hidden LEN dummy is passed by reference
78 if (c .ne. 4_"Made in test!") print *, c
79 if (len(c) .ne. 13) call abort
81 subroutine test_pass_c4 (carg)
82 character(:, kind = 4), allocatable :: carg
83 if (carg .ne. 4_"Goodbye") call abort
84 if (len(carg) .ne. 7) call abort
85 carg = 4_"Made in test!"