[LoopReroll] Add an extra defensive check to avoid SCEV assertion.
[llvm-project.git] / flang / test / Semantics / symbol17.f90
blob0b6b930804d91a6eeb913ceedf273de0ebab41fb
1 ! RUN: %S/test_symbols.sh %s %t %flang_fc1
2 ! REQUIRES: shell
3 ! Forward references to derived types (non-error cases)
5 !DEF: /main MainProgram
6 program main
7 !DEF: /main/t1 DerivedType
8 type :: t1
9 !DEF: /main/t2 DerivedType
10 !DEF: /main/t1/t1a ALLOCATABLE ObjectEntity TYPE(t2)
11 type(t2), allocatable :: t1a
12 !REF: /main/t2
13 !DEF: /main/t1/t1p POINTER ObjectEntity TYPE(t2)
14 type(t2), pointer :: t1p
15 end type
16 !REF: /main/t2
17 type :: t2
18 !REF: /main/t2
19 !DEF: /main/t2/t2a ALLOCATABLE ObjectEntity TYPE(t2)
20 type(t2), allocatable :: t2a
21 !REF: /main/t2
22 !DEF: /main/t2/t2p POINTER ObjectEntity TYPE(t2)
23 type(t2), pointer :: t2p
24 end type
25 !REF: /main/t1
26 !DEF: /main/t1x TARGET ObjectEntity TYPE(t1)
27 type(t1), target :: t1x
28 !REF: /main/t1x
29 !REF: /main/t1/t1a
30 allocate(t1x%t1a)
31 !REF: /main/t1x
32 !REF: /main/t1/t1p
33 !REF: /main/t1/t1a
34 t1x%t1p => t1x%t1a
35 !REF: /main/t1x
36 !REF: /main/t1/t1a
37 !REF: /main/t2/t2a
38 allocate(t1x%t1a%t2a)
39 !REF: /main/t1x
40 !REF: /main/t1/t1a
41 !REF: /main/t2/t2p
42 !REF: /main/t2/t2a
43 t1x%t1a%t2p => t1x%t1a%t2a
44 end program
45 !DEF: /f1/fwd DerivedType
46 !DEF: /f1 (Function) Subprogram TYPE(fwd)
47 !DEF: /f1/n (Implicit) ObjectEntity INTEGER(4)
48 type(fwd) function f1(n)
49 !REF: /f1/fwd
50 type :: fwd
51 !DEF: /f1/fwd/n ObjectEntity INTEGER(4)
52 integer :: n
53 end type
54 !DEF: /f1/f1 ObjectEntity TYPE(fwd)
55 !REF: /f1/fwd/n
56 !REF: /f1/n
57 f1%n = n
58 end function
59 !DEF: /s1 (Subroutine) Subprogram
60 !DEF: /s1/q1 (Implicit) ObjectEntity TYPE(fwd)
61 subroutine s1 (q1)
62 !DEF: /s1/fwd DerivedType
63 implicit type(fwd)(q)
64 !REF: /s1/fwd
65 type :: fwd
66 !DEF: /s1/fwd/n ObjectEntity INTEGER(4)
67 integer :: n
68 end type
69 !REF: /s1/q1
70 !REF: /s1/fwd/n
71 q1%n = 1
72 end subroutine
73 !DEF: /f2/fwdpdt DerivedType
74 !DEF: /f2/kind INTRINSIC, PURE (Function) ProcEntity
75 !DEF: /f2 (Function) Subprogram TYPE(fwdpdt(k=4_4))
76 !DEF: /f2/n (Implicit) ObjectEntity INTEGER(4)
77 type(fwdpdt(kind(0))) function f2(n)
78 !REF: /f2/fwdpdt
79 !DEF: /f2/fwdpdt/k TypeParam INTEGER(4)
80 type :: fwdpdt(k)
81 !REF: /f2/fwdpdt/k
82 integer, kind :: k
83 !REF: /f2/fwdpdt/k
84 !DEF: /f2/fwdpdt/n ObjectEntity INTEGER(int(int(k,kind=4),kind=8))
85 integer(kind=k) :: n
86 end type
87 !DEF: /f2/f2 ObjectEntity TYPE(fwdpdt(k=4_4))
88 !DEF: /f2/DerivedType2/n ObjectEntity INTEGER(4)
89 !REF: /f2/n
90 f2%n = n
91 end function
92 !DEF: /s2 (Subroutine) Subprogram
93 !DEF: /s2/q1 (Implicit) ObjectEntity TYPE(fwdpdt(k=4_4))
94 subroutine s2 (q1)
95 !DEF: /s2/fwdpdt DerivedType
96 !DEF: /s2/kind INTRINSIC, PURE (Function) ProcEntity
97 implicit type(fwdpdt(kind(0)))(q)
98 !REF: /s2/fwdpdt
99 !DEF: /s2/fwdpdt/k TypeParam INTEGER(4)
100 type :: fwdpdt(k)
101 !REF: /s2/fwdpdt/k
102 integer, kind :: k
103 !REF: /s2/fwdpdt/k
104 !DEF: /s2/fwdpdt/n ObjectEntity INTEGER(int(int(k,kind=4),kind=8))
105 integer(kind=k) :: n
106 end type
107 !REF: /s2/q1
108 !DEF: /s2/DerivedType2/n ObjectEntity INTEGER(4)
109 q1%n = 1
110 end subroutine
111 !DEF: /m1 Module
112 module m1
113 !DEF: /m1/forward PRIVATE DerivedType
114 private :: forward
115 !DEF: /m1/base PUBLIC DerivedType
116 type :: base
117 !REF: /m1/forward
118 !DEF: /m1/base/p POINTER ObjectEntity CLASS(forward)
119 class(forward), pointer :: p
120 end type
121 !REF: /m1/base
122 !REF: /m1/forward
123 type, extends(base) :: forward
124 !DEF: /m1/forward/n ObjectEntity INTEGER(4)
125 integer :: n
126 end type
127 contains
128 !DEF: /m1/test PUBLIC (Subroutine) Subprogram
129 subroutine test
130 !REF: /m1/forward
131 !DEF: /m1/test/object TARGET ObjectEntity TYPE(forward)
132 type(forward), target :: object
133 !REF: /m1/test/object
134 !REF: /m1/base/p
135 object%p => object
136 !REF: /m1/test/object
137 !REF: /m1/base/p
138 !REF: /m1/forward/n
139 object%p%n = 666
140 end subroutine
141 end module