PR inline-asm/84742
[official-gcc.git] / gcc / testsuite / gfortran.dg / func_derived_2.f90
blob2ac9dea869c3bc5f99b6f874a5a8b5bc8b0aa7bf
1 ! { dg-do run }
2 ! This tests the "virtual fix" for PR19561, where functions returning
3 ! pointers to derived types were not generating correct code. This
4 ! testcase is based on a simplified example in the PR discussion.
6 ! Submitted by Paul Thomas pault@gcc.gnu.org
7 ! Slightly extended by Tobias Schlüter
8 module mpoint
9 type :: mytype
10 integer :: i
11 end type mytype
13 contains
15 function get (a) result (b)
16 type (mytype), target :: a
17 type (mytype), pointer :: b
18 b => a
19 end function get
21 function get2 (a)
22 type (mytype), target :: a
23 type (mytype), pointer :: get2
24 get2 => a
25 end function get2
27 end module mpoint
29 program func_derived_2
30 use mpoint
31 type (mytype), target :: x
32 type (mytype), pointer :: y
33 x = mytype (42)
34 y => get (x)
35 if (y%i.ne.42) STOP 1
37 x = mytype (112)
38 y => get2 (x)
39 if (y%i.ne.112) STOP 2
40 end program func_derived_2