summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gfortran.dg/select_type_35.f03
blob: 92d2f27531311b76abf9dac25745f7c6dfe9bf05 (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
! { dg-do run }
!
! Contributed by Nathanael Huebbe
! Check fix for PR/70842

program foo

  TYPE, ABSTRACT :: t_Intermediate
  END TYPE t_Intermediate

  type, extends(t_Intermediate) :: t_Foo
    character(:), allocatable :: string
  end type t_Foo

  class(t_Foo), allocatable :: obj

  allocate(obj)
  obj%string = "blabarfoo"

  call bar(obj)

  deallocate(obj)
contains
  subroutine bar(me)
    class(t_Intermediate), target :: me

    class(*), pointer :: alias

    select type(me)
      type is(t_Foo)
      if (len(me%string) /= 9) call abort()
    end select

    alias => me
    select type(alias)
      type is(t_Foo)
        if (len(alias%string) /= 9) call abort()
    end select
  end subroutine bar
end program foo