aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gfortran.dg/associate_48.f90
blob: 5ce3a496d14a4c3f8e6b3a7d908a6cf5ff142a69 (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 }
!
! Test the fix for PR90498.
!
! Contributed by Vladimir Fuka  <vladimir.fuka@gmail.com>
!
  type field_names_a
    class(*), pointer :: var(:) =>null()
  end type

  type(field_names_a),pointer :: a(:)
  allocate (a(2))

  allocate (a(1)%var(2), source = ["hello"," vlad"])
  allocate (a(2)%var(2), source = ["HELLO"," VLAD"])
  call s(a)
  deallocate (a(1)%var)
  deallocate (a(2)%var)
  deallocate (a)
contains
  subroutine s(a)

    type(field_names_a) :: a(:)

    select type (var => a(1)%var)
      type is (character(*))
        if (any (var .ne. ["hello"," vlad"])) stop 1
      class default
        stop
    end select

    associate (var => a(2)%var)
      select type (var)
        type is (character(*))
          if (any (var .ne. ["HELLO"," VLAD"])) stop 2
        class default
          stop
      end select
    end associate
  end
end