blob: 3d65118aaf095c1f0be65eae282ddec85dcef75b (
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
51
52
53
54
55
56
57
58
59
60
61
62
|
! { dg-do run }
!
! Contributed by Thomas Fanning <thfanning@gmail.com>
!
!
module mod
type test
class(*), pointer :: ptr
contains
procedure :: setref
end type
contains
subroutine setref(my,ip)
implicit none
class(test) :: my
integer, pointer :: ip
my%ptr => ip
end subroutine
subroutine set7(ptr)
implicit none
class(*), pointer :: ptr
select type (ptr)
type is (integer)
ptr = 7
end select
end subroutine
end module
!---------------------------------------
!---------------------------------------
program bug
use mod
implicit none
integer, pointer :: i, j
type(test) :: tp
class(*), pointer :: lp
allocate(i,j)
i = 3; j = 4
call tp%setref(i)
select type (ap => tp%ptr)
class default
call tp%setref(j)
lp => ap
call set7(lp)
end select
! gfortran used to give i=3 and j=7 because the associate name was not pointing
! to the target of tp%ptr as required by F2018:19.5.1.6 but, rather, to the
! selector itself.
if (i .ne. 7) stop 1
if (j .ne. 4) stop 2
end program
!---------------------------------------
|