annotate clang/test/AST/fixed_point.c @ 207:2e18cbf3894f

LLVM12
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Tue, 08 Jun 2021 06:07:14 +0900
parents 1d019706d866
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
207
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
1 // Test without serialization:
150
anatofuz
parents:
diff changeset
2 // RUN: %clang_cc1 -x c -ffixed-point -ast-dump %s | FileCheck %s --strict-whitespace
207
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
3 //
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
4 // Test with serialization:
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
5 // RUN: %clang_cc1 -ffixed-point -emit-pch -o %t %s
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
6 // RUN: %clang_cc1 -x c -ffixed-point -include-pch %t -ast-dump-all /dev/null \
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
7 // RUN: | sed -e "s/ <undeserialized declarations>//" -e "s/ imported//" \
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
8 // RUN: | FileCheck %s --strict-whitespace
150
anatofuz
parents:
diff changeset
9
anatofuz
parents:
diff changeset
10 /* Various contexts where type _Accum can appear. */
anatofuz
parents:
diff changeset
11
anatofuz
parents:
diff changeset
12 // Primary fixed point types
anatofuz
parents:
diff changeset
13 signed short _Accum s_short_accum;
anatofuz
parents:
diff changeset
14 signed _Accum s_accum;
anatofuz
parents:
diff changeset
15 signed long _Accum s_long_accum;
anatofuz
parents:
diff changeset
16 unsigned short _Accum u_short_accum;
anatofuz
parents:
diff changeset
17 unsigned _Accum u_accum;
anatofuz
parents:
diff changeset
18 unsigned long _Accum u_long_accum;
anatofuz
parents:
diff changeset
19 signed short _Fract s_short_fract;
anatofuz
parents:
diff changeset
20 signed _Fract s_fract;
anatofuz
parents:
diff changeset
21 signed long _Fract s_long_fract;
anatofuz
parents:
diff changeset
22 unsigned short _Fract u_short_fract;
anatofuz
parents:
diff changeset
23 unsigned _Fract u_fract;
anatofuz
parents:
diff changeset
24 unsigned long _Fract u_long_fract;
anatofuz
parents:
diff changeset
25
anatofuz
parents:
diff changeset
26 // Aliased fixed point types
anatofuz
parents:
diff changeset
27 short _Accum short_accum;
anatofuz
parents:
diff changeset
28 _Accum accum;
anatofuz
parents:
diff changeset
29 long _Accum long_accum;
anatofuz
parents:
diff changeset
30 short _Fract short_fract;
anatofuz
parents:
diff changeset
31 _Fract fract;
anatofuz
parents:
diff changeset
32 long _Fract long_fract;
anatofuz
parents:
diff changeset
33
anatofuz
parents:
diff changeset
34 // Saturated fixed point types
anatofuz
parents:
diff changeset
35 _Sat signed short _Accum sat_s_short_accum;
anatofuz
parents:
diff changeset
36 _Sat signed _Accum sat_s_accum;
anatofuz
parents:
diff changeset
37 _Sat signed long _Accum sat_s_long_accum;
anatofuz
parents:
diff changeset
38 _Sat unsigned short _Accum sat_u_short_accum;
anatofuz
parents:
diff changeset
39 _Sat unsigned _Accum sat_u_accum;
anatofuz
parents:
diff changeset
40 _Sat unsigned long _Accum sat_u_long_accum;
anatofuz
parents:
diff changeset
41 _Sat signed short _Fract sat_s_short_fract;
anatofuz
parents:
diff changeset
42 _Sat signed _Fract sat_s_fract;
anatofuz
parents:
diff changeset
43 _Sat signed long _Fract sat_s_long_fract;
anatofuz
parents:
diff changeset
44 _Sat unsigned short _Fract sat_u_short_fract;
anatofuz
parents:
diff changeset
45 _Sat unsigned _Fract sat_u_fract;
anatofuz
parents:
diff changeset
46 _Sat unsigned long _Fract sat_u_long_fract;
anatofuz
parents:
diff changeset
47
anatofuz
parents:
diff changeset
48 // Aliased saturated fixed point types
anatofuz
parents:
diff changeset
49 _Sat short _Accum sat_short_accum;
anatofuz
parents:
diff changeset
50 _Sat _Accum sat_accum;
anatofuz
parents:
diff changeset
51 _Sat long _Accum sat_long_accum;
anatofuz
parents:
diff changeset
52 _Sat short _Fract sat_short_fract;
anatofuz
parents:
diff changeset
53 _Sat _Fract sat_fract;
anatofuz
parents:
diff changeset
54 _Sat long _Fract sat_long_fract;
anatofuz
parents:
diff changeset
55
anatofuz
parents:
diff changeset
56 //CHECK: |-VarDecl {{.*}} s_short_accum 'short _Accum'
anatofuz
parents:
diff changeset
57 //CHECK-NEXT: |-VarDecl {{.*}} s_accum '_Accum'
anatofuz
parents:
diff changeset
58 //CHECK-NEXT: |-VarDecl {{.*}} s_long_accum 'long _Accum'
anatofuz
parents:
diff changeset
59 //CHECK-NEXT: |-VarDecl {{.*}} u_short_accum 'unsigned short _Accum'
anatofuz
parents:
diff changeset
60 //CHECK-NEXT: |-VarDecl {{.*}} u_accum 'unsigned _Accum'
anatofuz
parents:
diff changeset
61 //CHECK-NEXT: |-VarDecl {{.*}} u_long_accum 'unsigned long _Accum'
anatofuz
parents:
diff changeset
62 //CHECK-NEXT: |-VarDecl {{.*}} s_short_fract 'short _Fract'
anatofuz
parents:
diff changeset
63 //CHECK-NEXT: |-VarDecl {{.*}} s_fract '_Fract'
anatofuz
parents:
diff changeset
64 //CHECK-NEXT: |-VarDecl {{.*}} s_long_fract 'long _Fract'
anatofuz
parents:
diff changeset
65 //CHECK-NEXT: |-VarDecl {{.*}} u_short_fract 'unsigned short _Fract'
anatofuz
parents:
diff changeset
66 //CHECK-NEXT: |-VarDecl {{.*}} u_fract 'unsigned _Fract'
anatofuz
parents:
diff changeset
67 //CHECK-NEXT: |-VarDecl {{.*}} u_long_fract 'unsigned long _Fract'
anatofuz
parents:
diff changeset
68 //CHECK-NEXT: |-VarDecl {{.*}} short_accum 'short _Accum'
anatofuz
parents:
diff changeset
69 //CHECK-NEXT: |-VarDecl {{.*}} accum '_Accum'
anatofuz
parents:
diff changeset
70 //CHECK-NEXT: |-VarDecl {{.*}} long_accum 'long _Accum'
anatofuz
parents:
diff changeset
71 //CHECK-NEXT: |-VarDecl {{.*}} short_fract 'short _Fract'
anatofuz
parents:
diff changeset
72 //CHECK-NEXT: |-VarDecl {{.*}} fract '_Fract'
anatofuz
parents:
diff changeset
73 //CHECK-NEXT: |-VarDecl {{.*}} long_fract 'long _Fract'
anatofuz
parents:
diff changeset
74 //CHECK-NEXT: |-VarDecl {{.*}} sat_s_short_accum '_Sat short _Accum'
anatofuz
parents:
diff changeset
75 //CHECK-NEXT: |-VarDecl {{.*}} sat_s_accum '_Sat _Accum'
anatofuz
parents:
diff changeset
76 //CHECK-NEXT: |-VarDecl {{.*}} sat_s_long_accum '_Sat long _Accum'
anatofuz
parents:
diff changeset
77 //CHECK-NEXT: |-VarDecl {{.*}} sat_u_short_accum '_Sat unsigned short _Accum'
anatofuz
parents:
diff changeset
78 //CHECK-NEXT: |-VarDecl {{.*}} sat_u_accum '_Sat unsigned _Accum'
anatofuz
parents:
diff changeset
79 //CHECK-NEXT: |-VarDecl {{.*}} sat_u_long_accum '_Sat unsigned long _Accum'
anatofuz
parents:
diff changeset
80 //CHECK-NEXT: |-VarDecl {{.*}} sat_s_short_fract '_Sat short _Fract'
anatofuz
parents:
diff changeset
81 //CHECK-NEXT: |-VarDecl {{.*}} sat_s_fract '_Sat _Fract'
anatofuz
parents:
diff changeset
82 //CHECK-NEXT: |-VarDecl {{.*}} sat_s_long_fract '_Sat long _Fract'
anatofuz
parents:
diff changeset
83 //CHECK-NEXT: |-VarDecl {{.*}} sat_u_short_fract '_Sat unsigned short _Fract'
anatofuz
parents:
diff changeset
84 //CHECK-NEXT: |-VarDecl {{.*}} sat_u_fract '_Sat unsigned _Fract'
anatofuz
parents:
diff changeset
85 //CHECK-NEXT: |-VarDecl {{.*}} sat_u_long_fract '_Sat unsigned long _Fract'
anatofuz
parents:
diff changeset
86 //CHECK-NEXT: |-VarDecl {{.*}} sat_short_accum '_Sat short _Accum'
anatofuz
parents:
diff changeset
87 //CHECK-NEXT: |-VarDecl {{.*}} sat_accum '_Sat _Accum'
anatofuz
parents:
diff changeset
88 //CHECK-NEXT: |-VarDecl {{.*}} sat_long_accum '_Sat long _Accum'
anatofuz
parents:
diff changeset
89 //CHECK-NEXT: |-VarDecl {{.*}} sat_short_fract '_Sat short _Fract'
anatofuz
parents:
diff changeset
90 //CHECK-NEXT: |-VarDecl {{.*}} sat_fract '_Sat _Fract'
anatofuz
parents:
diff changeset
91 //CHECK-NEXT: |-VarDecl {{.*}} sat_long_fract '_Sat long _Fract'
anatofuz
parents:
diff changeset
92
anatofuz
parents:
diff changeset
93 #define MIX_TYPE_SPEC(SPEC, SIGN, SIZE, ID) \
anatofuz
parents:
diff changeset
94 SPEC SIGN SIZE _Accum ID; \
anatofuz
parents:
diff changeset
95 SIGN SPEC SIZE _Accum ID ## 2; \
anatofuz
parents:
diff changeset
96 SIGN SIZE SPEC _Accum ID ## 3; \
anatofuz
parents:
diff changeset
97 SIGN SIZE _Accum SPEC ID ## 4;
anatofuz
parents:
diff changeset
98
anatofuz
parents:
diff changeset
99 /* Mixing fixed point types with other type specifiers */
anatofuz
parents:
diff changeset
100
anatofuz
parents:
diff changeset
101 #define MIX_VOLATILE(SIGN, SIZE, ID) MIX_TYPE_SPEC(volatile, SIGN, SIZE, ID)
anatofuz
parents:
diff changeset
102 #define MIX_ATOMIC(SIGN, SIZE, ID) MIX_TYPE_SPEC(_Atomic, SIGN, SIZE, ID)
anatofuz
parents:
diff changeset
103 #define MIX_CONST(SIGN, SIZE, ID) MIX_TYPE_SPEC(const, SIGN, SIZE, ID)
anatofuz
parents:
diff changeset
104
anatofuz
parents:
diff changeset
105 MIX_VOLATILE(signed, short, vol_s_short_accum)
anatofuz
parents:
diff changeset
106 MIX_ATOMIC(signed, short, atm_s_short_accum)
anatofuz
parents:
diff changeset
107 MIX_CONST(signed, short, const_s_short_accum)
anatofuz
parents:
diff changeset
108
anatofuz
parents:
diff changeset
109 // CHECK-NEXT: |-VarDecl {{.*}} vol_s_short_accum 'volatile short _Accum'
anatofuz
parents:
diff changeset
110 // CHECK-NEXT: |-VarDecl {{.*}} vol_s_short_accum2 'volatile short _Accum'
anatofuz
parents:
diff changeset
111 // CHECK-NEXT: |-VarDecl {{.*}} vol_s_short_accum3 'volatile short _Accum'
anatofuz
parents:
diff changeset
112 // CHECK-NEXT: |-VarDecl {{.*}} vol_s_short_accum4 'volatile short _Accum'
anatofuz
parents:
diff changeset
113
anatofuz
parents:
diff changeset
114 // CHECK-NEXT: |-VarDecl {{.*}} atm_s_short_accum '_Atomic(short _Accum)'
anatofuz
parents:
diff changeset
115 // CHECK-NEXT: |-VarDecl {{.*}} atm_s_short_accum2 '_Atomic(short _Accum)'
anatofuz
parents:
diff changeset
116 // CHECK-NEXT: |-VarDecl {{.*}} atm_s_short_accum3 '_Atomic(short _Accum)'
anatofuz
parents:
diff changeset
117 // CHECK-NEXT: |-VarDecl {{.*}} atm_s_short_accum4 '_Atomic(short _Accum)'
anatofuz
parents:
diff changeset
118
anatofuz
parents:
diff changeset
119 // CHECK-NEXT: |-VarDecl {{.*}} const_s_short_accum 'const short _Accum'
anatofuz
parents:
diff changeset
120 // CHECK-NEXT: |-VarDecl {{.*}} const_s_short_accum2 'const short _Accum'
anatofuz
parents:
diff changeset
121 // CHECK-NEXT: |-VarDecl {{.*}} const_s_short_accum3 'const short _Accum'
anatofuz
parents:
diff changeset
122 // CHECK-NEXT: |-VarDecl {{.*}} const_s_short_accum4 'const short _Accum'
anatofuz
parents:
diff changeset
123
anatofuz
parents:
diff changeset
124 /* Typedefs */
anatofuz
parents:
diff changeset
125
anatofuz
parents:
diff changeset
126 // Primary fixed point types
anatofuz
parents:
diff changeset
127 typedef signed short _Accum SsA_t;
anatofuz
parents:
diff changeset
128 typedef signed _Accum SA_t;
anatofuz
parents:
diff changeset
129 typedef signed long _Accum SlA_t;
anatofuz
parents:
diff changeset
130 typedef unsigned short _Accum UsA_t;
anatofuz
parents:
diff changeset
131 typedef unsigned _Accum UA_t;
anatofuz
parents:
diff changeset
132 typedef unsigned long _Accum UlA_t;
anatofuz
parents:
diff changeset
133 typedef signed short _Fract SsF_t;
anatofuz
parents:
diff changeset
134 typedef signed _Fract SF_t;
anatofuz
parents:
diff changeset
135 typedef signed long _Fract SlF_t;
anatofuz
parents:
diff changeset
136 typedef unsigned short _Fract UsF_t;
anatofuz
parents:
diff changeset
137 typedef unsigned _Fract UF_t;
anatofuz
parents:
diff changeset
138 typedef unsigned long _Fract UlF_t;
anatofuz
parents:
diff changeset
139
anatofuz
parents:
diff changeset
140 // Aliased fixed point types
anatofuz
parents:
diff changeset
141 typedef short _Accum sA_t;
anatofuz
parents:
diff changeset
142 typedef _Accum A_t;
anatofuz
parents:
diff changeset
143 typedef long _Accum lA_t;
anatofuz
parents:
diff changeset
144 typedef short _Fract sF_t;
anatofuz
parents:
diff changeset
145 typedef _Fract F_t;
anatofuz
parents:
diff changeset
146 typedef long _Fract lF_t;
anatofuz
parents:
diff changeset
147
anatofuz
parents:
diff changeset
148 // Saturated fixed point types
anatofuz
parents:
diff changeset
149 typedef _Sat signed short _Accum SatSsA_t;
anatofuz
parents:
diff changeset
150 typedef _Sat signed _Accum SatSA_t;
anatofuz
parents:
diff changeset
151 typedef _Sat signed long _Accum SatSlA_t;
anatofuz
parents:
diff changeset
152 typedef _Sat unsigned short _Accum SatUsA_t;
anatofuz
parents:
diff changeset
153 typedef _Sat unsigned _Accum SatUA_t;
anatofuz
parents:
diff changeset
154 typedef _Sat unsigned long _Accum SatUlA_t;
anatofuz
parents:
diff changeset
155 typedef _Sat signed short _Fract SatSsF_t;
anatofuz
parents:
diff changeset
156 typedef _Sat signed _Fract SatSF_t;
anatofuz
parents:
diff changeset
157 typedef _Sat signed long _Fract SatSlF_t;
anatofuz
parents:
diff changeset
158 typedef _Sat unsigned short _Fract SatUsF_t;
anatofuz
parents:
diff changeset
159 typedef _Sat unsigned _Fract SatUF_t;
anatofuz
parents:
diff changeset
160 typedef _Sat unsigned long _Fract SatUlF_t;
anatofuz
parents:
diff changeset
161
anatofuz
parents:
diff changeset
162 // Aliased saturated fixed point types
anatofuz
parents:
diff changeset
163 typedef _Sat short _Accum SatsA_t;
anatofuz
parents:
diff changeset
164 typedef _Sat _Accum SatA_t;
anatofuz
parents:
diff changeset
165 typedef _Sat long _Accum SatlA_t;
anatofuz
parents:
diff changeset
166 typedef _Sat short _Fract SatsF_t;
anatofuz
parents:
diff changeset
167 typedef _Sat _Fract SatF_t;
anatofuz
parents:
diff changeset
168 typedef _Sat long _Fract SatlF_t;
anatofuz
parents:
diff changeset
169
anatofuz
parents:
diff changeset
170 SsA_t SsA_type;
anatofuz
parents:
diff changeset
171 SA_t SA_type;
anatofuz
parents:
diff changeset
172 SlA_t SlA_type;
anatofuz
parents:
diff changeset
173 UsA_t UsA_type;
anatofuz
parents:
diff changeset
174 UA_t UA_type;
anatofuz
parents:
diff changeset
175 UlA_t UlA_type;
anatofuz
parents:
diff changeset
176 SsF_t SsF_type;
anatofuz
parents:
diff changeset
177 SF_t SF_type;
anatofuz
parents:
diff changeset
178 SlF_t SlF_type;
anatofuz
parents:
diff changeset
179 UsF_t UsF_type;
anatofuz
parents:
diff changeset
180 UF_t UF_type;
anatofuz
parents:
diff changeset
181 UlF_t UlF_type;
anatofuz
parents:
diff changeset
182
anatofuz
parents:
diff changeset
183 sA_t sA_type;
anatofuz
parents:
diff changeset
184 A_t A_type;
anatofuz
parents:
diff changeset
185 lA_t lA_type;
anatofuz
parents:
diff changeset
186 sF_t sF_type;
anatofuz
parents:
diff changeset
187 F_t F_type;
anatofuz
parents:
diff changeset
188 lF_t lF_type;
anatofuz
parents:
diff changeset
189
anatofuz
parents:
diff changeset
190 SatSsA_t SatSsA_type;
anatofuz
parents:
diff changeset
191 SatSA_t SatSA_type;
anatofuz
parents:
diff changeset
192 SatSlA_t SatSlA_type;
anatofuz
parents:
diff changeset
193 SatUsA_t SatUsA_type;
anatofuz
parents:
diff changeset
194 SatUA_t SatUA_type;
anatofuz
parents:
diff changeset
195 SatUlA_t SatUlA_type;
anatofuz
parents:
diff changeset
196 SatSsF_t SatSsF_type;
anatofuz
parents:
diff changeset
197 SatSF_t SatSF_type;
anatofuz
parents:
diff changeset
198 SatSlF_t SatSlF_type;
anatofuz
parents:
diff changeset
199 SatUsF_t SatUsF_type;
anatofuz
parents:
diff changeset
200 SatUF_t SatUF_type;
anatofuz
parents:
diff changeset
201 SatUlF_t SatUlF_type;
anatofuz
parents:
diff changeset
202
anatofuz
parents:
diff changeset
203 SatsA_t SatsA_type;
anatofuz
parents:
diff changeset
204 SatA_t SatA_type;
anatofuz
parents:
diff changeset
205 SatlA_t SatlA_type;
anatofuz
parents:
diff changeset
206 SatsF_t SatsF_type;
anatofuz
parents:
diff changeset
207 SatF_t SatF_type;
anatofuz
parents:
diff changeset
208 SatlF_t SatlF_type;
anatofuz
parents:
diff changeset
209
anatofuz
parents:
diff changeset
210 //CHECK: |-VarDecl {{.*}} SsA_type 'SsA_t':'short _Accum'
anatofuz
parents:
diff changeset
211 //CHECK-NEXT: |-VarDecl {{.*}} SA_type 'SA_t':'_Accum'
anatofuz
parents:
diff changeset
212 //CHECK-NEXT: |-VarDecl {{.*}} SlA_type 'SlA_t':'long _Accum'
anatofuz
parents:
diff changeset
213 //CHECK-NEXT: |-VarDecl {{.*}} UsA_type 'UsA_t':'unsigned short _Accum'
anatofuz
parents:
diff changeset
214 //CHECK-NEXT: |-VarDecl {{.*}} UA_type 'UA_t':'unsigned _Accum'
anatofuz
parents:
diff changeset
215 //CHECK-NEXT: |-VarDecl {{.*}} UlA_type 'UlA_t':'unsigned long _Accum'
anatofuz
parents:
diff changeset
216 //CHECK-NEXT: |-VarDecl {{.*}} SsF_type 'SsF_t':'short _Fract'
anatofuz
parents:
diff changeset
217 //CHECK-NEXT: |-VarDecl {{.*}} SF_type 'SF_t':'_Fract'
anatofuz
parents:
diff changeset
218 //CHECK-NEXT: |-VarDecl {{.*}} SlF_type 'SlF_t':'long _Fract'
anatofuz
parents:
diff changeset
219 //CHECK-NEXT: |-VarDecl {{.*}} UsF_type 'UsF_t':'unsigned short _Fract'
anatofuz
parents:
diff changeset
220 //CHECK-NEXT: |-VarDecl {{.*}} UF_type 'UF_t':'unsigned _Fract'
anatofuz
parents:
diff changeset
221 //CHECK-NEXT: |-VarDecl {{.*}} UlF_type 'UlF_t':'unsigned long _Fract'
anatofuz
parents:
diff changeset
222 //CHECK-NEXT: |-VarDecl {{.*}} sA_type 'sA_t':'short _Accum'
anatofuz
parents:
diff changeset
223 //CHECK-NEXT: |-VarDecl {{.*}} A_type 'A_t':'_Accum'
anatofuz
parents:
diff changeset
224 //CHECK-NEXT: |-VarDecl {{.*}} lA_type 'lA_t':'long _Accum'
anatofuz
parents:
diff changeset
225 //CHECK-NEXT: |-VarDecl {{.*}} sF_type 'sF_t':'short _Fract'
anatofuz
parents:
diff changeset
226 //CHECK-NEXT: |-VarDecl {{.*}} F_type 'F_t':'_Fract'
anatofuz
parents:
diff changeset
227 //CHECK-NEXT: |-VarDecl {{.*}} lF_type 'lF_t':'long _Fract'
anatofuz
parents:
diff changeset
228
anatofuz
parents:
diff changeset
229 //CHECK-NEXT: |-VarDecl {{.*}} SatSsA_type 'SatSsA_t':'_Sat short _Accum'
anatofuz
parents:
diff changeset
230 //CHECK-NEXT: |-VarDecl {{.*}} SatSA_type 'SatSA_t':'_Sat _Accum'
anatofuz
parents:
diff changeset
231 //CHECK-NEXT: |-VarDecl {{.*}} SatSlA_type 'SatSlA_t':'_Sat long _Accum'
anatofuz
parents:
diff changeset
232 //CHECK-NEXT: |-VarDecl {{.*}} SatUsA_type 'SatUsA_t':'_Sat unsigned short _Accum'
anatofuz
parents:
diff changeset
233 //CHECK-NEXT: |-VarDecl {{.*}} SatUA_type 'SatUA_t':'_Sat unsigned _Accum'
anatofuz
parents:
diff changeset
234 //CHECK-NEXT: |-VarDecl {{.*}} SatUlA_type 'SatUlA_t':'_Sat unsigned long _Accum'
anatofuz
parents:
diff changeset
235 //CHECK-NEXT: |-VarDecl {{.*}} SatSsF_type 'SatSsF_t':'_Sat short _Fract'
anatofuz
parents:
diff changeset
236 //CHECK-NEXT: |-VarDecl {{.*}} SatSF_type 'SatSF_t':'_Sat _Fract'
anatofuz
parents:
diff changeset
237 //CHECK-NEXT: |-VarDecl {{.*}} SatSlF_type 'SatSlF_t':'_Sat long _Fract'
anatofuz
parents:
diff changeset
238 //CHECK-NEXT: |-VarDecl {{.*}} SatUsF_type 'SatUsF_t':'_Sat unsigned short _Fract'
anatofuz
parents:
diff changeset
239 //CHECK-NEXT: |-VarDecl {{.*}} SatUF_type 'SatUF_t':'_Sat unsigned _Fract'
anatofuz
parents:
diff changeset
240 //CHECK-NEXT: |-VarDecl {{.*}} SatUlF_type 'SatUlF_t':'_Sat unsigned long _Fract'
anatofuz
parents:
diff changeset
241 //CHECK-NEXT: |-VarDecl {{.*}} SatsA_type 'SatsA_t':'_Sat short _Accum'
anatofuz
parents:
diff changeset
242 //CHECK-NEXT: |-VarDecl {{.*}} SatA_type 'SatA_t':'_Sat _Accum'
anatofuz
parents:
diff changeset
243 //CHECK-NEXT: |-VarDecl {{.*}} SatlA_type 'SatlA_t':'_Sat long _Accum'
anatofuz
parents:
diff changeset
244 //CHECK-NEXT: |-VarDecl {{.*}} SatsF_type 'SatsF_t':'_Sat short _Fract'
anatofuz
parents:
diff changeset
245 //CHECK-NEXT: |-VarDecl {{.*}} SatF_type 'SatF_t':'_Sat _Fract'
anatofuz
parents:
diff changeset
246 //CHECK-NEXT: |-VarDecl {{.*}} SatlF_type 'SatlF_t':'_Sat long _Fract'
anatofuz
parents:
diff changeset
247
anatofuz
parents:
diff changeset
248 // Fixed point literal exponent syntax
anatofuz
parents:
diff changeset
249 _Accum decexp1 = 1.575e1k;
anatofuz
parents:
diff changeset
250 _Accum decexp2 = 1.575E1k;
anatofuz
parents:
diff changeset
251 _Accum decexp3 = 1575e-2k;
anatofuz
parents:
diff changeset
252 _Accum decexp4 = 1575E-2k;
anatofuz
parents:
diff changeset
253
anatofuz
parents:
diff changeset
254 _Accum hexexp1 = 0x0.3p10k;
anatofuz
parents:
diff changeset
255 _Accum hexexp2 = 0x0.3P10k;
anatofuz
parents:
diff changeset
256 _Accum hexexp3 = 0x30000p-10k;
anatofuz
parents:
diff changeset
257 _Accum hexexp4 = 0x30000P-10k;
anatofuz
parents:
diff changeset
258
anatofuz
parents:
diff changeset
259 _Accum zeroexp1 = 1e0k;
anatofuz
parents:
diff changeset
260 _Accum zeroexp2 = 1e-0k;
anatofuz
parents:
diff changeset
261
anatofuz
parents:
diff changeset
262 //CHECK-NEXT: |-VarDecl {{.*}} decexp1 '_Accum' cinit
anatofuz
parents:
diff changeset
263 //CHECK-NEXT: `-FixedPointLiteral {{.*}} '_Accum' 15.75
anatofuz
parents:
diff changeset
264 //CHECK-NEXT: |-VarDecl {{.*}} decexp2 '_Accum' cinit
anatofuz
parents:
diff changeset
265 //CHECK-NEXT: `-FixedPointLiteral {{.*}} '_Accum' 15.75
anatofuz
parents:
diff changeset
266 //CHECK-NEXT: |-VarDecl {{.*}} decexp3 '_Accum' cinit
anatofuz
parents:
diff changeset
267 //CHECK-NEXT: `-FixedPointLiteral {{.*}} '_Accum' 15.75
anatofuz
parents:
diff changeset
268 //CHECK-NEXT: |-VarDecl {{.*}} decexp4 '_Accum' cinit
anatofuz
parents:
diff changeset
269 //CHECK-NEXT: `-FixedPointLiteral {{.*}} '_Accum' 15.75
anatofuz
parents:
diff changeset
270
anatofuz
parents:
diff changeset
271 //CHECK-NEXT: |-VarDecl {{.*}} hexexp1 '_Accum' cinit
anatofuz
parents:
diff changeset
272 //CHECK-NEXT: `-FixedPointLiteral {{.*}} '_Accum' 192.0
anatofuz
parents:
diff changeset
273 //CHECK-NEXT: |-VarDecl {{.*}} hexexp2 '_Accum' cinit
anatofuz
parents:
diff changeset
274 //CHECK-NEXT: `-FixedPointLiteral {{.*}} '_Accum' 192.0
anatofuz
parents:
diff changeset
275 //CHECK-NEXT: |-VarDecl {{.*}} hexexp3 '_Accum' cinit
anatofuz
parents:
diff changeset
276 //CHECK-NEXT: `-FixedPointLiteral {{.*}} '_Accum' 192.0
anatofuz
parents:
diff changeset
277 //CHECK-NEXT: |-VarDecl {{.*}} hexexp4 '_Accum' cinit
anatofuz
parents:
diff changeset
278 //CHECK-NEXT: `-FixedPointLiteral {{.*}} '_Accum' 192.0
anatofuz
parents:
diff changeset
279
anatofuz
parents:
diff changeset
280 //CHECK-NEXT: |-VarDecl {{.*}} zeroexp1 '_Accum' cinit
anatofuz
parents:
diff changeset
281 //CHECK-NEXT: `-FixedPointLiteral {{.*}} '_Accum' 1.0
anatofuz
parents:
diff changeset
282 //CHECK-NEXT: |-VarDecl {{.*}} zeroexp2 '_Accum' cinit
anatofuz
parents:
diff changeset
283 //CHECK-NEXT: `-FixedPointLiteral {{.*}} '_Accum' 1.0
anatofuz
parents:
diff changeset
284
anatofuz
parents:
diff changeset
285 // Fixed point literal values
anatofuz
parents:
diff changeset
286 _Accum literal1 = 2.5k; // Precise decimal
anatofuz
parents:
diff changeset
287 _Accum literal2 = 0.0k; // Zero
anatofuz
parents:
diff changeset
288 _Accum literal3 = 1.1k; // Imprecise decimal
anatofuz
parents:
diff changeset
289 _Accum literal4 = 1.11k;
anatofuz
parents:
diff changeset
290 _Accum literal5 = 1.111k;
anatofuz
parents:
diff changeset
291 _Accum literal6 = 1.1111k;
anatofuz
parents:
diff changeset
292 _Accum literal7 = 1.11111k; // After some point after the radix, adding any more
anatofuz
parents:
diff changeset
293 // digits to the literal will not result in any
anatofuz
parents:
diff changeset
294 // further precision since the nth digit added may
anatofuz
parents:
diff changeset
295 // be less than the precision that can be
anatofuz
parents:
diff changeset
296 // represented by the fractional bits of the type.
anatofuz
parents:
diff changeset
297 // This results in the same value being stored for
anatofuz
parents:
diff changeset
298 // the type.
anatofuz
parents:
diff changeset
299
anatofuz
parents:
diff changeset
300 //CHECK-NEXT: |-VarDecl {{.*}} literal1 '_Accum' cinit
anatofuz
parents:
diff changeset
301 //CHECK-NEXT: `-FixedPointLiteral {{.*}} '_Accum' 2.5
anatofuz
parents:
diff changeset
302 //CHECK-NEXT: |-VarDecl {{.*}} literal2 '_Accum' cinit
anatofuz
parents:
diff changeset
303 //CHECK-NEXT: `-FixedPointLiteral {{.*}} '_Accum' 0.0
anatofuz
parents:
diff changeset
304 //CHECK-NEXT: |-VarDecl {{.*}} literal3 '_Accum' cinit
anatofuz
parents:
diff changeset
305 //CHECK-NEXT: `-FixedPointLiteral {{.*}} '_Accum' 1.0999755859375
anatofuz
parents:
diff changeset
306 //CHECK-NEXT: |-VarDecl {{.*}} literal4 '_Accum' cinit
anatofuz
parents:
diff changeset
307 //CHECK-NEXT: `-FixedPointLiteral {{.*}} '_Accum' 1.1099853515625
anatofuz
parents:
diff changeset
308 //CHECK-NEXT: |-VarDecl {{.*}} literal5 '_Accum' cinit
anatofuz
parents:
diff changeset
309 //CHECK-NEXT: `-FixedPointLiteral {{.*}} '_Accum' 1.110992431640625
anatofuz
parents:
diff changeset
310 //CHECK-NEXT: |-VarDecl {{.*}} literal6 '_Accum' cinit
anatofuz
parents:
diff changeset
311 //CHECK-NEXT: `-FixedPointLiteral {{.*}} '_Accum' 1.111083984375
anatofuz
parents:
diff changeset
312 //CHECK-NEXT: |-VarDecl {{.*}} literal7 '_Accum' cinit
anatofuz
parents:
diff changeset
313 //CHECK-NEXT: `-FixedPointLiteral {{.*}} '_Accum' 1.111083984375
anatofuz
parents:
diff changeset
314
anatofuz
parents:
diff changeset
315 long _Accum longaccumliteral = 0.99999999lk;
anatofuz
parents:
diff changeset
316 long _Accum longaccumliteral2 = 0.999999999lk;
anatofuz
parents:
diff changeset
317 long _Accum verylongaccumliteral = 0.99999999999999999999999999lk;
anatofuz
parents:
diff changeset
318 long _Fract longfractliteral = 0.99999999lr;
anatofuz
parents:
diff changeset
319 long _Fract longfractliteral2 = 0.999999999lr;
anatofuz
parents:
diff changeset
320 long _Fract verylongfractliteral = 0.99999999999999999999999999lr;
anatofuz
parents:
diff changeset
321
anatofuz
parents:
diff changeset
322 //CHECK-NEXT: |-VarDecl {{.*}} longaccumliteral 'long _Accum' cinit
anatofuz
parents:
diff changeset
323 //CHECK-NEXT: `-FixedPointLiteral {{.*}} 'long _Accum' 0.999999989755451679229736328125
anatofuz
parents:
diff changeset
324 //CHECK-NEXT: |-VarDecl {{.*}} longaccumliteral2 'long _Accum' cinit
anatofuz
parents:
diff changeset
325 //CHECK-NEXT: `-FixedPointLiteral {{.*}} 'long _Accum' 0.9999999986030161380767822265625
anatofuz
parents:
diff changeset
326 //CHECK-NEXT: |-VarDecl {{.*}} verylongaccumliteral 'long _Accum' cinit
anatofuz
parents:
diff changeset
327 //CHECK-NEXT: `-FixedPointLiteral {{.*}} 'long _Accum' 0.9999999995343387126922607421875
anatofuz
parents:
diff changeset
328 //CHECK-NEXT: |-VarDecl {{.*}} longfractliteral 'long _Fract' cinit
anatofuz
parents:
diff changeset
329 //CHECK-NEXT: `-FixedPointLiteral {{.*}} 'long _Fract' 0.999999989755451679229736328125
anatofuz
parents:
diff changeset
330 //CHECK-NEXT: |-VarDecl {{.*}} longfractliteral2 'long _Fract' cinit
anatofuz
parents:
diff changeset
331 //CHECK-NEXT: `-FixedPointLiteral {{.*}} 'long _Fract' 0.9999999986030161380767822265625
anatofuz
parents:
diff changeset
332 //CHECK-NEXT: |-VarDecl {{.*}} verylongfractliteral 'long _Fract' cinit
anatofuz
parents:
diff changeset
333 //CHECK-NEXT: `-FixedPointLiteral {{.*}} 'long _Fract' 0.9999999995343387126922607421875
anatofuz
parents:
diff changeset
334
anatofuz
parents:
diff changeset
335 unsigned _Accum uliteral1 = 2.5uk; // Unsigned
anatofuz
parents:
diff changeset
336 _Accum literal8 = -2.5k; // Negative
anatofuz
parents:
diff changeset
337
anatofuz
parents:
diff changeset
338 //CHECK-NEXT: |-VarDecl {{.*}} uliteral1 'unsigned _Accum' cinit
anatofuz
parents:
diff changeset
339 //CHECK-NEXT: `-FixedPointLiteral {{.*}} 'unsigned _Accum' 2.5
anatofuz
parents:
diff changeset
340 //CHECK-NEXT: |-VarDecl {{.*}} literal8 '_Accum' cinit
anatofuz
parents:
diff changeset
341 //CHECK-NEXT: `-UnaryOperator {{.*}} '_Accum' prefix '-'
anatofuz
parents:
diff changeset
342 //CHECK-NEXT: `-FixedPointLiteral {{.*}} '_Accum' 2.5
anatofuz
parents:
diff changeset
343
anatofuz
parents:
diff changeset
344 short _Accum literalexact1 = 0.9921875hk; // Exact value
anatofuz
parents:
diff changeset
345 _Accum literalexact2 = 0.999969482421875k;
anatofuz
parents:
diff changeset
346
anatofuz
parents:
diff changeset
347 //CHECK-NEXT: |-VarDecl {{.*}} literalexact1 'short _Accum' cinit
anatofuz
parents:
diff changeset
348 //CHECK-NEXT: `-FixedPointLiteral {{.*}} 'short _Accum' 0.9921875
anatofuz
parents:
diff changeset
349 //CHECK-NEXT: |-VarDecl {{.*}} literalexact2 '_Accum' cinit
anatofuz
parents:
diff changeset
350 //CHECK-NEXT: `-FixedPointLiteral {{.*}} '_Accum' 0.999969482421875
anatofuz
parents:
diff changeset
351
anatofuz
parents:
diff changeset
352 // Unfortunately we do not have enough space to store the exact decimal value of
anatofuz
parents:
diff changeset
353 // 0.9999999995343387126922607421875 ((1 << 31) - 1), but we can still use a
anatofuz
parents:
diff changeset
354 // large number of 9s to get the max fractional value.
anatofuz
parents:
diff changeset
355 long _Accum long_accum_max = 0.999999999999999999999999999lk;
anatofuz
parents:
diff changeset
356
anatofuz
parents:
diff changeset
357 //CHECK-NEXT: |-VarDecl {{.*}} long_accum_max 'long _Accum' cinit
anatofuz
parents:
diff changeset
358 //CHECK-NEXT: `-FixedPointLiteral {{.*}} 'long _Accum' 0.9999999995343387126922607421875
anatofuz
parents:
diff changeset
359
anatofuz
parents:
diff changeset
360 // Epsilon
anatofuz
parents:
diff changeset
361 short _Accum short_accum_eps = 0.0078125hk;
anatofuz
parents:
diff changeset
362 short _Accum short_accum_eps2 = 0.0078124hk; // Less than epsilon floors to zero
anatofuz
parents:
diff changeset
363 _Accum accum_eps = 0.000030517578125k;
anatofuz
parents:
diff changeset
364 _Accum accum_eps2 = 0.000030517578124k;
anatofuz
parents:
diff changeset
365 long _Accum long_accum_eps = 0x1p-31lk;
anatofuz
parents:
diff changeset
366 long _Accum long_accum_eps2 = 0x0.99999999p-31lk;
anatofuz
parents:
diff changeset
367
anatofuz
parents:
diff changeset
368 //CHECK-NEXT: |-VarDecl {{.*}} short_accum_eps 'short _Accum' cinit
anatofuz
parents:
diff changeset
369 //CHECK-NEXT: `-FixedPointLiteral {{.*}} 'short _Accum' 0.0078125
anatofuz
parents:
diff changeset
370 //CHECK-NEXT: |-VarDecl {{.*}} short_accum_eps2 'short _Accum' cinit
anatofuz
parents:
diff changeset
371 //CHECK-NEXT: `-FixedPointLiteral {{.*}} 'short _Accum' 0.0
anatofuz
parents:
diff changeset
372 //CHECK-NEXT: |-VarDecl {{.*}} accum_eps '_Accum' cinit
anatofuz
parents:
diff changeset
373 //CHECK-NEXT: `-FixedPointLiteral {{.*}} '_Accum' 0.000030517578125
anatofuz
parents:
diff changeset
374 //CHECK-NEXT: |-VarDecl {{.*}} accum_eps2 '_Accum' cinit
anatofuz
parents:
diff changeset
375 //CHECK-NEXT: `-FixedPointLiteral {{.*}} '_Accum' 0.0
anatofuz
parents:
diff changeset
376 //CHECK-NEXT: |-VarDecl {{.*}} long_accum_eps 'long _Accum' cinit
anatofuz
parents:
diff changeset
377 //CHECK-NEXT: `-FixedPointLiteral {{.*}} 'long _Accum' 0.0000000004656612873077392578125
anatofuz
parents:
diff changeset
378 //CHECK-NEXT: |-VarDecl {{.*}} long_accum_eps2 'long _Accum' cinit
anatofuz
parents:
diff changeset
379 //CHECK-NEXT: `-FixedPointLiteral {{.*}} 'long _Accum' 0.0
anatofuz
parents:
diff changeset
380
anatofuz
parents:
diff changeset
381 // Fract literals can be one but evaluate to the respective Fract max
anatofuz
parents:
diff changeset
382 short _Fract short_fract_one = 1.0hr;
anatofuz
parents:
diff changeset
383 _Fract fract_one = 1.0r;
anatofuz
parents:
diff changeset
384 long _Fract long_fract_one = 1.0lr;
anatofuz
parents:
diff changeset
385 unsigned short _Fract u_short_fract_one = 1.0uhr;
anatofuz
parents:
diff changeset
386 unsigned _Fract u_fract_one = 1.0ur;
anatofuz
parents:
diff changeset
387 unsigned long _Fract u_long_fract_one = 1.0ulr;
anatofuz
parents:
diff changeset
388
anatofuz
parents:
diff changeset
389 //CHECK-NEXT: |-VarDecl {{.*}} short_fract_one 'short _Fract' cinit
anatofuz
parents:
diff changeset
390 //CHECK-NEXT: `-FixedPointLiteral {{.*}} 'short _Fract' 0.9921875
anatofuz
parents:
diff changeset
391 //CHECK-NEXT: |-VarDecl {{.*}} fract_one '_Fract' cinit
anatofuz
parents:
diff changeset
392 //CHECK-NEXT: `-FixedPointLiteral {{.*}} '_Fract' 0.999969482421875
anatofuz
parents:
diff changeset
393 //CHECK-NEXT: |-VarDecl {{.*}} long_fract_one 'long _Fract' cinit
anatofuz
parents:
diff changeset
394 //CHECK-NEXT: `-FixedPointLiteral {{.*}} 'long _Fract' 0.9999999995343387126922607421875
anatofuz
parents:
diff changeset
395
anatofuz
parents:
diff changeset
396 //CHECK-NEXT: |-VarDecl {{.*}} u_short_fract_one 'unsigned short _Fract' cinit
anatofuz
parents:
diff changeset
397 //CHECK-NEXT: `-FixedPointLiteral {{.*}} 'unsigned short _Fract' 0.99609375
anatofuz
parents:
diff changeset
398 //CHECK-NEXT: |-VarDecl {{.*}} u_fract_one 'unsigned _Fract' cinit
anatofuz
parents:
diff changeset
399 //CHECK-NEXT: `-FixedPointLiteral {{.*}} 'unsigned _Fract' 0.9999847412109375
anatofuz
parents:
diff changeset
400 //CHECK-NEXT: |-VarDecl {{.*}} u_long_fract_one 'unsigned long _Fract' cinit
anatofuz
parents:
diff changeset
401 //CHECK-NEXT: `-FixedPointLiteral {{.*}} 'unsigned long _Fract' 0.99999999976716935634613037109375
anatofuz
parents:
diff changeset
402
anatofuz
parents:
diff changeset
403 _Accum literallast = 1.0k; // One
anatofuz
parents:
diff changeset
404
anatofuz
parents:
diff changeset
405 //CHECK-NEXT: `-VarDecl {{.*}} literallast '_Accum' cinit
anatofuz
parents:
diff changeset
406 //CHECK-NEXT: `-FixedPointLiteral {{.*}} '_Accum' 1.0