summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gfortran.dg/class_1.f03
blob: f21133a05adf32a01e1449ab2d4eeb1c183d13e0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
! { dg-do run }
!
! PR 40940: CLASS statement
!
! Contributed by Janus Weil <janus@gcc.gnu.org>

implicit none

type t
  integer :: comp
  class(t),pointer :: c2
end type

class(t),pointer :: c1

allocate(c1)

c1%comp = 5
c1%c2 => c1

print *,c1%comp

call sub(c1)

if (c1%comp/=5) call abort()

deallocate(c1)

contains

  subroutine sub (c3)
    class(t) :: c3
    print *,c3%comp
  end subroutine

end