2 ! { dg-options "-fdump-tree-original" }
6 ! Compile-time simplification of SAME_TYPE_AS and EXTENDS_TYPE_OF.
12 type, extends(t1
):: t11
15 type, extends(t11
):: t111
25 class(t1
), allocatable
:: b1
26 class(t11
), allocatable
:: b11
27 class(t2
), allocatable
:: b2
29 logical, parameter :: p1
= same_type_as(a1
,a2
) ! F
30 logical, parameter :: p2
= same_type_as(a2
,a1
) ! F
31 logical, parameter :: p3
= same_type_as(a1
,a11
) ! F
32 logical, parameter :: p4
= same_type_as(a11
,a1
) ! F
33 logical, parameter :: p5
= same_type_as(a11
,a11
)! T
34 logical, parameter :: p6
= same_type_as(a1
,a1
) ! T
36 if (p1
.or
. p2
.or
. p3
.or
. p4
.or
. .not
. p5
.or
. .not
. p6
) call should_not_exist()
38 if (same_type_as(b1
,b1
) .neqv
. .true
.) call should_not_exist()
40 ! Not (trivially) compile-time simplifiable:
41 if (same_type_as(b1
,a1
) .neqv
. .true
.) call abort()
42 if (same_type_as(b1
,a11
) .neqv
. .false
.) call abort()
44 if (same_type_as(b1
,a1
) .neqv
. .true
.) call abort()
45 if (same_type_as(b1
,a11
) .neqv
. .false
.) call abort()
48 if (same_type_as(b1
,a1
) .neqv
. .false
.) call abort()
49 if (same_type_as(b1
,a11
) .neqv
. .true
.) call abort()
54 if (extends_type_of(a1
,a1
) .neqv
. .true
.) call should_not_exist()
55 if (extends_type_of(a11
,a11
) .neqv
. .true
.) call should_not_exist()
56 if (extends_type_of(a2
,a2
) .neqv
. .true
.) call should_not_exist()
58 ! .false. -> type compatibility possible
59 if (extends_type_of(a1
,a2
) .neqv
. .false
.) call should_not_exist()
60 if (extends_type_of(a2
,a1
) .neqv
. .false
.) call should_not_exist()
61 if (extends_type_of(a11
,a2
) .neqv
. .false
.) call should_not_exist()
62 if (extends_type_of(a2
,a11
) .neqv
. .false
.) call should_not_exist()
64 if (extends_type_of(b1
,b2
) .neqv
. .false
.) call should_not_exist()
65 if (extends_type_of(b2
,b1
) .neqv
. .false
.) call should_not_exist()
66 if (extends_type_of(b11
,b2
) .neqv
. .false
.) call should_not_exist()
67 if (extends_type_of(b2
,b11
) .neqv
. .false
.) call should_not_exist()
69 if (extends_type_of(b1
,a2
) .neqv
. .false
.) call should_not_exist()
70 if (extends_type_of(b2
,a1
) .neqv
. .false
.) call should_not_exist()
71 if (extends_type_of(b11
,a2
) .neqv
. .false
.) call should_not_exist()
72 if (extends_type_of(b2
,a11
) .neqv
. .false
.) call should_not_exist()
74 if (extends_type_of(a1
,b2
) .neqv
. .false
.) call should_not_exist()
75 if (extends_type_of(a2
,b1
) .neqv
. .false
.) call should_not_exist()
76 if (extends_type_of(a11
,b2
) .neqv
. .false
.) call should_not_exist()
77 if (extends_type_of(a2
,b11
) .neqv
. .false
.) call should_not_exist()
79 ! type extension possible, compile-time checkable
80 if (extends_type_of(a1
,a11
) .neqv
. .false
.) call should_not_exist()
81 if (extends_type_of(a11
,a1
) .neqv
. .true
.) call should_not_exist()
83 if (extends_type_of(b1
,a1
) .neqv
. .true
.) call should_not_exist()
84 if (extends_type_of(b11
,a1
) .neqv
. .true
.) call should_not_exist()
85 if (extends_type_of(b11
,a11
) .neqv
. .true
.) call should_not_exist()
87 if (extends_type_of(a1
,b11
) .neqv
. .false
.) call should_not_exist()
90 ! Special case, simplified at tree folding:
91 if (extends_type_of(b1
,b1
) .neqv
. .true
.) call abort()
93 ! All other possibilities are not compile-time checkable
94 if (extends_type_of(b11
,b1
) .neqv
. .true
.) call abort()
95 if (extends_type_of(b1
,b11
) .neqv
. .false
.) call abort()
96 if (extends_type_of(a11
,b11
) .neqv
. .true
.) call abort()
99 if (extends_type_of(a11
,b11
) .neqv
. .true
.) call abort()
102 allocate(t111
:: b11
)
103 if (extends_type_of(a11
,b11
) .neqv
. .false
.) call abort()
107 if (extends_type_of(a11
,b1
) .neqv
. .true
.) call abort()
111 if (extends_type_of(b1
,a11
) .neqv
. .true
.) call abort()
114 allocate(b1
,source
=a11
)
115 if (extends_type_of(b1
,a11
) .neqv
. .true
.) call abort()
118 allocate( b1
,source
=a1
)
119 if (extends_type_of(b1
,a11
) .neqv
. .false
.) call abort()
124 ! { dg-final { scan-tree-dump-times "abort" 16 "original" } }
125 ! { dg-final { scan-tree-dump-times "should_not_exist" 0 "original" } }