OSDN Git Service

2009-10-16 Janus Weil <janus@gcc.gnu.org>
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / gfortran.dg / class_5.f03
1 ! { dg-do compile }
2 !
3 ! PR 41719: [OOP] invalid: Intrinsic assignment involving polymorphic variables
4 !
5 ! Contributed by Tobias Burnus <burnus@gcc.gnu.org>
6
7  implicit none
8
9  type t1
10    integer :: a
11  end type
12
13  type, extends(t1) :: t2
14    integer :: b
15  end type
16
17  class(t1),pointer :: cp
18  type(t2) :: x
19
20  x = t2(45,478)
21  allocate(t2 :: cp)
22
23  cp = x   ! { dg-error "Variable must not be polymorphic" }
24
25  select type (cp)
26  type is (t2)
27    print *, cp%a, cp%b
28  end select
29
30 end
31