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