arm: Add .type and .size to __gnu_cmse_nonsecure_call [PR115360]
[official-gcc.git] / gcc / testsuite / gfortran.dg / realloc_on_assign_4.f03
blob308db8fb04baaa8ff05fa6aee6f172e30d76fc58
1 ! { dg-do run }
2 ! Tests function return of deferred length scalars.
4 ! Contributed by Paul Thomas  <pault@gcc.gnu.org>
6 module m
7 contains
8   function mfoo (carg) result(res)
9     character (:), allocatable :: res
10     character (*) :: carg
11     res = carg(2:4)
12   end function
13   function mbar (carg)
14     character (:), allocatable :: mbar
15     character (*) :: carg
16     mbar = carg(2:13)
17   end function
18 end module
20   use m
21   character (:), allocatable :: lhs
22   lhs = foo ("foo calling ")
23   if (lhs .ne. "foo") STOP 1
24   if (len (lhs) .ne. 3) STOP 2
25   deallocate (lhs)
26   lhs = bar ("bar calling - baaaa!")
27   if (lhs .ne. "bar calling") STOP 3
28   if (len (lhs) .ne. 12) STOP 4
29   deallocate (lhs)
30   lhs = mfoo ("mfoo calling ")
31   if (lhs .ne. "foo") STOP 5
32   if (len (lhs) .ne. 3) STOP 6
33   deallocate (lhs)
34   lhs = mbar ("mbar calling - baaaa!")
35   if (lhs .ne. "bar calling") STOP 7
36   if (len (lhs) .ne. 12) STOP 8
37 contains
38   function foo (carg) result(res)
39     character (:), allocatable :: res
40     character (*) :: carg
41     res = carg(1:3)
42   end function
43   function bar (carg)
44     character (:), allocatable :: bar
45     character (*) :: carg
46     bar = carg(1:12)
47   end function
48 end