summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gfortran.dg/select_type_44.f90
blob: 8a5b5709b5aa952e02544e14e02e907787a4ac15 (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
! { dg-do run }
!
! Test the fix for PR87566
!
! Contributed by Antony Lewis  <antony@cosmologist.info>
!
  call AddArray
contains
  subroutine AddArray()
    type Object_array_pointer
        class(*), pointer :: p(:) => null()
    end type Object_array_pointer
    class(*), pointer :: Pt => null()
    type (Object_array_pointer) :: obj
    character(3), target :: tgt1(2) = ['one','two']
    character(5), target :: tgt2(2) = ['three','four ']

    allocate (Pt, source = Object_array_pointer ())
    select type (Pt)
      type is (object_array_pointer)
        Pt%p => tgt1
    end select

    select type (Pt)
      class is (object_array_pointer)
        select type (Point=> Pt%P)
          type is (character(*))
            if (any (Point .ne. tgt1)) stop 1
            Point = ['abc','efg']
        end select
    end select

    select type (Pt)
      class is (object_array_pointer)
        select type (Point=> Pt%P)
          type is (character(*))
            if (any (Point .ne. ['abc','efg'])) stop 2
        end select
    end select

  end subroutine AddArray
end