modula2: Simplify REAL/LONGREAL/SHORTREAL node creation.
[official-gcc.git] / gcc / testsuite / gfortran.dg / class_allocate_3.f03
blobe29b1c016a451b81eda32848efae1643ede75c2d
1 ! { dg-do run }
3 ! PR 41581: [OOP] Allocation of a CLASS with SOURCE=<class> does not work
5 ! Contributed by Tobias Burnus <burnus@gcc.gnu.org>
7  type t
8  end type t
10  type,extends(t) :: t2
11    integer :: i = 54
12    real :: r = 384.02
13  end type t2
15  class(t), allocatable :: m1, m2
17  allocate(t2 :: m2)
18  select type(m2)
19  type is (t2)
20    print *, m2%i, m2%r
21    if (m2%i/=54) STOP 1
22    if (abs(m2%r-384.02)>1E-3) STOP 2
23    m2%i = 42
24    m2%r = -4.0
25  class default
26    STOP 3
27  end select
29  allocate(m1, source=m2)
30  select type(m1)
31  type is (t2)
32    print *, m1%i, m1%r
33    if (m1%i/=42) STOP 4
34    if (abs(m1%r+4.0)>1E-3) STOP 5
35  class default
36    STOP 6
37  end select
39 end