1! { dg-do run }
2!
3! PR 47180: [OOP] EXTENDS_TYPE_OF returns the wrong result for disassociated polymorphic pointers 
4!
5! Contributed by Tobias Burnus <burnus@gcc.gnu.org>
6
7implicit none
8
9type t1
10  integer :: a
11end type t1
12
13type, extends(t1):: t11
14  integer :: b
15end type t11
16
17type(t1)  , target  :: a1
18type(t11) , target  :: a11
19class(t1) , pointer :: b1
20class(t11), pointer :: b11
21
22b1  => NULL()
23b11 => NULL()
24
25if (.not. extends_type_of(b1 , a1)) call abort()
26if (.not. extends_type_of(b11, a1)) call abort()
27if (.not. extends_type_of(b11,a11)) call abort()
28
29b1  => a1
30b11 => a11
31
32if (.not. extends_type_of(b1 , a1)) call abort()
33if (.not. extends_type_of(b11, a1)) call abort()
34if (.not. extends_type_of(b11,a11)) call abort()
35
36end
37