[flang] Accept polymorphic component element in storage_size
[llvm-project.git] / flang / test / Semantics / symbol11.f90
blob37029369795fb3274efa46650cb9ef309216a6f8
1 ! RUN: %python %S/test_symbols.py %s %flang_fc1
2 !DEF: /s1 (Subroutine) Subprogram
3 subroutine s1
4 implicit none
5 !DEF: /s1/x ObjectEntity REAL(8)
6 real(kind=8) :: x = 2.0
7 !DEF: /s1/a ObjectEntity INTEGER(4)
8 integer a
9 !DEF: /s1/t DerivedType
10 type :: t
11 end type
12 !REF: /s1/t
13 !DEF: /s1/z ALLOCATABLE ObjectEntity CLASS(t)
14 class(t), allocatable :: z
15 !DEF: /s1/OtherConstruct1/a AssocEntity REAL(8)
16 !REF: /s1/x
17 !DEF: /s1/OtherConstruct1/b AssocEntity REAL(8)
18 !DEF: /s1/OtherConstruct1/c AssocEntity CLASS(t)
19 !REF: /s1/z
20 associate (a => x, b => x+1, c => z)
21 !REF: /s1/x
22 !REF: /s1/OtherConstruct1/a
23 x = a
24 end associate
25 end subroutine
27 !DEF: /s2 (Subroutine) Subprogram
28 subroutine s2
29 !DEF: /s2/x ObjectEntity CHARACTER(4_4,1)
30 !DEF: /s2/y ObjectEntity CHARACTER(4_4,1)
31 character(len=4) x, y
32 !DEF: /s2/OtherConstruct1/z AssocEntity CHARACTER(4_8,1)
33 !REF: /s2/x
34 associate (z => x)
35 !REF: /s2/OtherConstruct1/z
36 print *, "z:", z
37 end associate
38 !TODO: need correct length for z
39 !DEF: /s2/OtherConstruct2/z AssocEntity CHARACTER(8_8,1)
40 !REF: /s2/x
41 !REF: /s2/y
42 associate (z => x//y)
43 !REF: /s2/OtherConstruct2/z
44 print *, "z:", z
45 end associate
46 end subroutine
48 !DEF: /s3 (Subroutine) Subprogram
49 subroutine s3
50 !DEF: /s3/t1 DerivedType
51 type :: t1
52 !DEF: /s3/t1/a1 ObjectEntity INTEGER(4)
53 integer :: a1
54 end type
55 !REF: /s3/t1
56 !DEF: /s3/t2 DerivedType
57 type, extends(t1) :: t2
58 !DEF: /s3/t2/a2 ObjectEntity INTEGER(4)
59 integer :: a2
60 end type
61 !DEF: /s3/i ObjectEntity INTEGER(4)
62 integer i
63 !REF: /s3/t1
64 !DEF: /s3/x POINTER ObjectEntity CLASS(t1)
65 class(t1), pointer :: x
66 !REF: /s3/x
67 select type (y => x)
68 !REF: /s3/t2
69 class is (t2)
70 !REF: /s3/i
71 !DEF: /s3/OtherConstruct1/y TARGET AssocEntity CLASS(t2)
72 !REF: /s3/t2/a2
73 i = y%a2
74 !REF: /s3/t1
75 type is (t1)
76 !REF: /s3/i
77 !DEF: /s3/OtherConstruct2/y TARGET AssocEntity TYPE(t1)
78 !REF: /s3/t1/a1
79 i = y%a1
80 class default
81 !DEF: /s3/OtherConstruct3/y TARGET AssocEntity CLASS(t1)
82 !REF:/s3/t1/a1
83 print *, y%a1
84 end select
85 end subroutine
87 !DEF: /s4 (Subroutine) Subprogram
88 subroutine s4
89 !DEF: /s4/t1 DerivedType
90 type :: t1
91 !DEF: /s4/t1/a ObjectEntity REAL(4)
92 real :: a
93 end type
94 !DEF: /s4/t2 DerivedType
95 type :: t2
96 !REF: /s4/t1
97 !DEF: /s4/t2/b ObjectEntity TYPE(t1)
98 type(t1) :: b
99 end type
100 !REF: /s4/t2
101 !DEF: /s4/x ObjectEntity TYPE(t2)
102 type(t2) :: x
103 !DEF: /s4/OtherConstruct1/y AssocEntity TYPE(t1)
104 !REF: /s4/x
105 !REF: /s4/t2/b
106 associate(y => x%b)
107 !REF: /s4/OtherConstruct1/y
108 !REF: /s4/t1/a
109 y%a = 0.0
110 end associate
111 end subroutine
113 !DEF: /s5 (Subroutine) Subprogram
114 subroutine s5
115 !DEF: /s5/t DerivedType
116 type :: t
117 !DEF: /s5/t/a ObjectEntity REAL(4)
118 real :: a
119 end type
120 !DEF: /s5/b ObjectEntity REAL(4)
121 real b
122 !DEF: /s5/OtherConstruct1/x AssocEntity TYPE(t)
123 !DEF: /s5/f (Function) Subprogram TYPE(t)
124 associate(x => f())
125 !REF: /s5/b
126 !REF: /s5/OtherConstruct1/x
127 !REF: /s5/t/a
128 b = x%a
129 end associate
130 contains
131 !REF: /s5/f
132 function f()
133 !REF: /s5/t
134 !DEF: /s5/f/f ObjectEntity TYPE(t)
135 type(t) :: f
136 end function
137 end subroutine