aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.9/gcc/testsuite/gfortran.dg/select_type_24.f90
blob: e47d00030f49972ec2356ff0595a57e556a395f9 (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
! { dg-do compile }
!
! PR fortran/48887
!
! "If the selector is allocatable, it shall be allocated; the
!  associate name is associated with the data object and does
!  not have the ALLOCATABLE attribute."
!
module m
  type t
  end type t
contains
  subroutine one(a)
    class(t), allocatable :: a
    class(t), allocatable :: b
    allocate (b)
    select type (b)
      type is(t)
        call move_alloc (b, a) ! { dg-error "must be ALLOCATABLE" }
    end select
  end subroutine one

  subroutine two (a)
    class(t), allocatable :: a
    type(t), allocatable :: b
    allocate (b)
    associate (c => b)
      call move_alloc (b, c) ! { dg-error "must be ALLOCATABLE" }
    end associate
  end subroutine two
end module m

type t
end type t
class(t), allocatable :: x

select type(x)
  type is(t)
    print *, allocated (x) ! { dg-error "must be ALLOCATABLE" }
end select

select type(y=>x)
  type is(t)
    print *, allocated (y)  ! { dg-error "must be ALLOCATABLE" }
end select

associate (y=>x)
  print *, allocated (y)  ! { dg-error "must be ALLOCATABLE" }
end associate
end