aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.9/gcc/testsuite/gfortran.dg/move_alloc_9.f90
blob: bf3f7b1b73f4107e13d54e208faf41b0b5281b23 (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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
! { dg-do compile }
!
! Test diagnostic for MOVE_ALLOC:
! FROM=type, TO=class is OK
! FROM=class, TO=type is INVALID
!
module m2
  type, abstract :: t2
  contains
    procedure(intf), deferred, nopass :: f
  end type t2

  interface
    function intf()
      import
      class(t2), allocatable :: intf
    end function intf
  end interface
end module m2

module m3
  use m2
  type, extends(t2) :: t3
  contains
    procedure,nopass :: f => my_f
  end type t3
contains
   function my_f()
     class(t2), allocatable :: my_f
   end function my_f
end module m3

subroutine my_test
use m3
type(t3), allocatable :: x
class(t2), allocatable :: y
call move_alloc (x, y)
end subroutine my_test

program testmv1
  type bar
  end type

  type, extends(bar) ::  bar2
  end type

  class(bar), allocatable :: sm
  type(bar2), allocatable :: sm2

  allocate (sm2)
  call move_alloc (sm,sm2) ! { dg-error "must be polymorphic if FROM is polymorphic" }

  if (allocated(sm2)) call abort()
  if (.not. allocated(sm)) call abort()
end program