summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gfortran.dg/unlimited_polymorphic_30.f03
blob: 4d0c2e7250bdc8aa751c568d8ae72e331230ed8d (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
! { dg-do run }
!
! Test the fix for PR83318.
!
! Contributed by Neil Carlson  <neil.n.carlson@gmail.com>
!
type :: any_vector
  class(*), allocatable :: v(:)
end type
type(any_vector) :: x, y

! This did not work correctly
  x%v = ['foo','bar']
  call foo (x, 1)

! This was reported as not working correctly but was OK before the above was fixed
  y = x
  call foo (y, 2)

  x%v = [1_4,2_4]
  call foo (x, 3)

  y = x
  call foo (y, 4)

contains

  subroutine foo (arg, n)
    type (any_vector) :: arg
    integer :: n
    select type (v => arg%v)
        type is (character(*))
           if (any (v .ne. ["foo","bar"])) stop n
        type is (integer(4))
           if (any (v .ne. [1_4,2_4])) stop n
    end select
  end subroutine
end