-
Notifications
You must be signed in to change notification settings - Fork 76
Expand file tree
/
Copy pathtest.cpp
More file actions
561 lines (534 loc) · 35.8 KB
/
Copy pathtest.cpp
File metadata and controls
561 lines (534 loc) · 35.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
// Assumed platform in qltest is linux_x86_64, so
// int, long, long long sizes are assumed to be 32, 64, 64 bits respectively
// The type of an integer constant is determined by "6.4.4.1 Integer constants"
// in the C11 Standard. The principle is that any decimal integer constant will
// be signed, unless it has the `U` or `u` suffix. Any hexadecimal integer will
// depend on whether it is larger than the maximum value of the smallest signed
// integer value that can hold the value. So the signedness depends on the
// magnitude of the constant.
void test_decimal_constants() {
0; // COMPLIANT
2147483648; // COMPLIANT - larger than int, but decimal constants never use
// unsigned without the suffix, so will be `long`
4294967296; // COMPLIANT - larger than unsigned int, still `long`
9223372036854775807; // COMPLIANT - max long int
// 9223372036854775808; Not a valid integer constant, out of signed range
0U; // COMPLIANT - unsigned, but uses the suffix correctly
2147483648U; // COMPLIANT - unsigned, but uses the suffix correctly
4294967296U; // COMPLIANT - unsigned, but uses the suffix correctly
9223372036854775807U; // COMPLIANT - max long int
9223372036854775808U; // COMPLIANT - explicitly unsigned, so can go large than
// max long int
0u; // COMPLIANT - unsigned, but uses the suffix correctly
2147483648u; // COMPLIANT - unsigned, but uses the suffix correctly
4294967296u; // COMPLIANT - unsigned, but uses the suffix correctly
9223372036854775807u; // COMPLIANT - max long int
9223372036854775808u; // COMPLIANT - explicitly unsigned, so can go large than
// max long int
// l suffix
0l; // COMPLIANT
2147483648l; // COMPLIANT - within the range of long int
4294967296l; // COMPLIANT - within the range of long int
9223372036854775807l; // COMPLIANT - max long int
// 9223372036854775808l; Not a valid integer constant, out of signed range
0lU; // COMPLIANT - unsigned, but uses the suffix correctly
2147483648lU; // COMPLIANT - unsigned, but uses the suffix correctly
4294967296lU; // COMPLIANT - unsigned, but uses the suffix correctly
9223372036854775807lU; // COMPLIANT - max long int
9223372036854775808lU; // COMPLIANT - explicitly unsigned, so can go large
// than max long int
0lu; // COMPLIANT - unsigned, but uses the suffix correctly
2147483648lu; // COMPLIANT - unsigned, but uses the suffix correctly
4294967296lu; // COMPLIANT - unsigned, but uses the suffix correctly
9223372036854775807lu; // COMPLIANT - max long int
9223372036854775808lu; // COMPLIANT - explicitly unsigned, so can go large
// than max long int
// L suffix
0L; // COMPLIANT
2147483648L; // COMPLIANT - within the range of long int
4294967296L; // COMPLIANT - within the range of long int
9223372036854775807L; // COMPLIANT - max long int
// 9223372036854775808L; Not a valid integer constant, out of signed range
0LU; // COMPLIANT - unsigned, but uses the suffix correctly
2147483648LU; // COMPLIANT - unsigned, but uses the suffix correctly
4294967296LU; // COMPLIANT - unsigned, but uses the suffix correctly
9223372036854775807LU; // COMPLIANT - max long int
9223372036854775808LU; // COMPLIANT - explicitly unsigned, so can go large
// than max long int
0Lu; // COMPLIANT - unsigned, but uses the suffix correctly
2147483648Lu; // COMPLIANT - unsigned, but uses the suffix correctly
4294967296Lu; // COMPLIANT - unsigned, but uses the suffix correctly
9223372036854775807Lu; // COMPLIANT - max long int
9223372036854775808Lu; // COMPLIANT - explicitly unsigned, so can go large
// than max long int
// ll suffix
0ll; // COMPLIANT
2147483648ll; // COMPLIANT - within the range of long long int
4294967296ll; // COMPLIANT - within the range of long long int
9223372036854775807ll; // COMPLIANT - max long long int
// 9223372036854775808ll; Not a valid integer constant, out of signed range
0llU; // COMPLIANT - unsigned, but uses the suffix correctly
2147483648llU; // COMPLIANT - unsigned, but uses the suffix correctly
4294967296llU; // COMPLIANT - unsigned, but uses the suffix correctly
9223372036854775807llU; // COMPLIANT - max long long int
9223372036854775808llU; // COMPLIANT - explicitly unsigned, so can go large
// than max long long int
0llu; // COMPLIANT - unsigned, but uses the suffix correctly
2147483648llu; // COMPLIANT - unsigned, but uses the suffix correctly
4294967296llu; // COMPLIANT - unsigned, but uses the suffix correctly
9223372036854775807llu; // COMPLIANT - max long long int
9223372036854775808llu; // COMPLIANT - explicitly unsigned, so can go large
// than max long long int
// LL suffix
0LL; // COMPLIANT
2147483648LL; // COMPLIANT - within the range of long long int
4294967296LL; // COMPLIANT - within the range of long long int
9223372036854775807LL; // COMPLIANT - max long long int
// 9223372036854775808LL; Not a valid integer constant, out of signed range
0LLU; // COMPLIANT - unsigned, but uses the suffix correctly
2147483648LLU; // COMPLIANT - unsigned, but uses the suffix correctly
4294967296LLU; // COMPLIANT - unsigned, but uses the suffix correctly
9223372036854775807LLU; // COMPLIANT - max long long int
9223372036854775808LLU; // COMPLIANT - explicitly unsigned, so can go large
// than max long long int
0LLu; // COMPLIANT - unsigned, but uses the suffix correctly
2147483648LLu; // COMPLIANT - unsigned, but uses the suffix correctly
4294967296LLu; // COMPLIANT - unsigned, but uses the suffix correctly
9223372036854775807LLu; // COMPLIANT - max long long int
9223372036854775808LLu; // COMPLIANT - explicitly unsigned, so can go large
// than max long long int
}
constexpr unsigned long long operator""_km(unsigned long long value) {
return value;
}
void test_user_defined_literal_exclusion() {
0x80000000_km; // COMPLIANT - user-defined literal argument should be excluded
}
template <typename T>
unsigned long long instantiated_literal_exclusion() {
return 0x80000000; // COMPLIANT - template instantiation should be excluded
}
void test_instantiated_literal_exclusion() { instantiated_literal_exclusion<int>(); }
void test_hexadecimal_constants() {
0x0; // COMPLIANT - uses signed int
0x7FFFFFFF; // COMPLIANT - max value held by signed int
0x80000000; // NON_COMPLIANT - larger than max signed int, so will be unsigned
// int
0x100000000; // COMPLIANT - larger than unsigned int, but smaller than long
// int
0x7FFFFFFFFFFFFFFF; // COMPLIANT - max long int
0x8000000000000000; // NON_COMPLIANT - larger than long int, so will be
// unsigned long int
0x0U; // COMPLIANT - unsigned, but uses the suffix correctly
0x7FFFFFFFU; // COMPLIANT - unsigned, but uses the suffix correctly
0x80000000U; // COMPLIANT - unsigned, but uses the suffix correctly
0x100000000U; // COMPLIANT - unsigned, but uses the suffix correctly
0x7FFFFFFFFFFFFFFFU; // COMPLIANT - unsigned, but uses the suffix correctly
0x8000000000000000U; // COMPLIANT - unsigned, but uses the suffix correctly
0x0u; // COMPLIANT - unsigned, but uses the suffix correctly
0x7FFFFFFFu; // COMPLIANT - unsigned, but uses the suffix correctly
0x80000000u; // COMPLIANT - unsigned, but uses the suffix correctly
0x100000000u; // COMPLIANT - unsigned, but uses the suffix correctly
0x7FFFFFFFFFFFFFFFu; // COMPLIANT - unsigned, but uses the suffix correctly
0x8000000000000000u; // COMPLIANT - unsigned, but uses the suffix correctly
// Use of the `l` suffix
0x0l; // COMPLIANT - uses signed int
0x7FFFFFFFl; // COMPLIANT - max value held by signed int
0x80000000l; // COMPLIANT - larger than max signed int, but smaller than long
// int
0x100000000l; // COMPLIANT - larger than unsigned int, but smaller than long
// int
0x7FFFFFFFFFFFFFFFl; // COMPLIANT - max long int
0x8000000000000000l; // NON_COMPLIANT - larger than long int, so will be
// unsigned long int
0x0lU; // COMPLIANT - unsigned, but uses the suffix correctly
0x7FFFFFFFlU; // COMPLIANT - unsigned, but uses the suffix correctly
0x80000000lU; // COMPLIANT - unsigned, but uses the suffix correctly
0x100000000lU; // COMPLIANT - unsigned, but uses the suffix correctly
0x7FFFFFFFFFFFFFFFlU; // COMPLIANT - unsigned, but uses the suffix correctly
0x8000000000000000lU; // COMPLIANT - unsigned, but uses the suffix correctly
0x0lu; // COMPLIANT - unsigned, but uses the suffix correctly
0x7FFFFFFFlu; // COMPLIANT - unsigned, but uses the suffix correctly
0x80000000lu; // COMPLIANT - unsigned, but uses the suffix correctly
0x100000000lu; // COMPLIANT - unsigned, but uses the suffix correctly
0x7FFFFFFFFFFFFFFFlu; // COMPLIANT - unsigned, but uses the suffix correctly
0x8000000000000000lu; // COMPLIANT - unsigned, but uses the suffix correctly
// Use of the `L` suffix
0x0L; // COMPLIANT - uses signed int
0x7FFFFFFFL; // COMPLIANT - max value held by signed int
0x80000000L; // COMPLIANT - larger than max signed int, but smaller than long
// int
0x100000000L; // COMPLIANT - larger than unsigned int, but smaller than long
// int
0x7FFFFFFFFFFFFFFFL; // COMPLIANT - max long int
0x8000000000000000L; // NON_COMPLIANT - larger than long int, so will be
// unsigned long int
0x0LU; // COMPLIANT - unsigned, but uses the suffix correctly
0x7FFFFFFFLU; // COMPLIANT - unsigned, but uses the suffix correctly
0x80000000LU; // COMPLIANT - unsigned, but uses the suffix correctly
0x100000000LU; // COMPLIANT - unsigned, but uses the suffix correctly
0x7FFFFFFFFFFFFFFFLU; // COMPLIANT - unsigned, but uses the suffix correctly
0x8000000000000000LU; // COMPLIANT - unsigned, but uses the suffix correctly
0x0Lu; // COMPLIANT - unsigned, but uses the suffix correctly
0x7FFFFFFFLu; // COMPLIANT - unsigned, but uses the suffix correctly
0x80000000Lu; // COMPLIANT - unsigned, but uses the suffix correctly
0x100000000Lu; // COMPLIANT - unsigned, but uses the suffix correctly
0x7FFFFFFFFFFFFFFFLu; // COMPLIANT - unsigned, but uses the suffix correctly
0x8000000000000000Lu; // COMPLIANT - unsigned, but uses the suffix correctly
// Use of the `ll` suffix
0x0ll; // COMPLIANT - uses signed int
0x7FFFFFFFll; // COMPLIANT - max value held by signed int
0x80000000ll; // COMPLIANT - larger than max signed int, but smaller than long
// long int
0x100000000ll; // COMPLIANT - larger than unsigned int, but smaller than long
// long int
0x7FFFFFFFFFFFFFFFll; // COMPLIANT - max long long int
0x8000000000000000ll; // NON_COMPLIANT - larger than long long int, so will be
// unsigned long long int
0x0llU; // COMPLIANT - unsigned, but uses the suffix correctly
0x7FFFFFFFllU; // COMPLIANT - unsigned, but uses the suffix correctly
0x80000000llU; // COMPLIANT - unsigned, but uses the suffix correctly
0x100000000llU; // COMPLIANT - unsigned, but uses the suffix correctly
0x7FFFFFFFFFFFFFFFllU; // COMPLIANT - unsigned, but uses the suffix correctly
0x8000000000000000llU; // COMPLIANT - unsigned, but uses the suffix correctly
0x0llu; // COMPLIANT - unsigned, but uses the suffix correctly
0x7FFFFFFFllu; // COMPLIANT - unsigned, but uses the suffix correctly
0x80000000llu; // COMPLIANT - unsigned, but uses the suffix correctly
0x100000000llu; // COMPLIANT - unsigned, but uses the suffix correctly
0x7FFFFFFFFFFFFFFFllu; // COMPLIANT - unsigned, but uses the suffix correctly
0x8000000000000000llu; // COMPLIANT - unsigned, but uses the suffix correctly
// Use of the `LL` suffix
0x0LL; // COMPLIANT - uses signed int
0x7FFFFFFFLL; // COMPLIANT - max value held by signed int
0x80000000LL; // COMPLIANT - larger than max signed int, but smaller than long
// long int
0x100000000LL; // COMPLIANT - larger than unsigned int, but smaller than long
// long int
0x7FFFFFFFFFFFFFFFLL; // COMPLIANT - max long long int
0x8000000000000000LL; // NON_COMPLIANT - larger than long long int, so will be
// unsigned long long int
0x0LLU; // COMPLIANT - unsigned, but uses the suffix correctly
0x7FFFFFFFLLU; // COMPLIANT - unsigned, but uses the suffix correctly
0x80000000LLU; // COMPLIANT - unsigned, but uses the suffix correctly
0x100000000LLU; // COMPLIANT - unsigned, but uses the suffix correctly
0x7FFFFFFFFFFFFFFFLLU; // COMPLIANT - unsigned, but uses the suffix correctly
0x8000000000000000LLU; // COMPLIANT - unsigned, but uses the suffix correctly
0x0LLu; // COMPLIANT - unsigned, but uses the suffix correctly
0x7FFFFFFFLLu; // COMPLIANT - unsigned, but uses the suffix correctly
0x80000000LLu; // COMPLIANT - unsigned, but uses the suffix correctly
0x100000000LLu; // COMPLIANT - unsigned, but uses the suffix correctly
0x7FFFFFFFFFFFFFFFLLu; // COMPLIANT - unsigned, but uses the suffix correctly
0x8000000000000000LLu; // COMPLIANT - unsigned, but uses the suffix correctly
}
void test_octal_constants() {
00; // COMPLIANT - uses signed int
017777777777; // COMPLIANT - max value held by signed int
020000000000; // NON_COMPLIANT - larger than max signed int, so will be
// unsigned int
040000000000; // COMPLIANT - larger than unsigned int, but smaller than long
// int
0777777777777777777777; // COMPLIANT - max long int
01000000000000000000000; // NON_COMPLIANT - larger than long int, so will be
// unsigned long int
00U; // COMPLIANT - unsigned, but uses the suffix correctly
017777777777U; // COMPLIANT - unsigned, but uses the suffix correctly
020000000000U; // COMPLIANT - unsigned, but uses the suffix correctly
040000000000U; // COMPLIANT - unsigned, but uses the suffix correctly
0777777777777777777777U; // COMPLIANT - unsigned, but uses the suffix
// correctly
01000000000000000000000U; // COMPLIANT - unsigned, but uses the suffix
// correctly
// Use of the `l` suffix
00l; // COMPLIANT - uses signed long
017777777777l; // COMPLIANT - uses signed long
020000000000l; // COMPLIANT - uses signed long
040000000000l; // COMPLIANT - uses signed long
0777777777777777777777l; // COMPLIANT - max long int
01000000000000000000000l; // NON_COMPLIANT - larger than long int, so will be
// unsigned long int
00Ul; // COMPLIANT - unsigned, but uses the suffix correctly
017777777777Ul; // COMPLIANT - unsigned, but uses the suffix correctly
020000000000Ul; // COMPLIANT - unsigned, but uses the suffix correctly
040000000000Ul; // COMPLIANT - unsigned, but uses the suffix correctly
0777777777777777777777Ul; // COMPLIANT - unsigned, but uses the suffix
// correctly
01000000000000000000000Ul; // COMPLIANT - unsigned, but uses the suffix
// correctly
// Use of the `L` suffix
00L; // COMPLIANT - uses signed long
017777777777L; // COMPLIANT - uses signed long
020000000000L; // COMPLIANT - uses signed long
040000000000L; // COMPLIANT - uses signed long
0777777777777777777777L; // COMPLIANT - COMPLIANT - uses signed long
01000000000000000000000L; // NON_COMPLIANT - larger than long int, so will be
// unsigned long int
00UL; // COMPLIANT - unsigned, but uses the suffix correctly
017777777777UL; // COMPLIANT - unsigned, but uses the suffix correctly
020000000000UL; // COMPLIANT - unsigned, but uses the suffix correctly
040000000000UL; // COMPLIANT - unsigned, but uses the suffix correctly
0777777777777777777777UL; // COMPLIANT - unsigned, but uses the suffix
// correctly
01000000000000000000000UL; // COMPLIANT - unsigned, but uses the suffix
// correctly
// Use of the `ll` suffix
00ll; // COMPLIANT - uses signed long long
017777777777ll; // COMPLIANT - uses signed long long
020000000000ll; // COMPLIANT - uses signed long long
040000000000ll; // COMPLIANT - uses signed long long
0777777777777777777777ll; // COMPLIANT - max long int
01000000000000000000000ll; // NON_COMPLIANT - larger than long int, so will be
// unsigned long int
00Ull; // COMPLIANT - unsigned, but uses the suffix correctly
017777777777Ull; // COMPLIANT - unsigned, but uses the suffix correctly
020000000000Ull; // COMPLIANT - unsigned, but uses the suffix correctly
040000000000Ull; // COMPLIANT - unsigned, but uses the suffix correctly
0777777777777777777777Ull; // COMPLIANT - unsigned, but uses the suffix
// correctly
01000000000000000000000Ull; // COMPLIANT - unsigned, but uses the suffix
// correctly
// Use of the `LL` suffix
00LL; // COMPLIANT - uses signed long long
017777777777LL; // COMPLIANT - uses signed long long
020000000000LL; // COMPLIANT - uses signed long long
040000000000LL; // COMPLIANT - uses signed long long
0777777777777777777777LL; // COMPLIANT - max long int
01000000000000000000000LL; // NON_COMPLIANT - larger than long int, so will be
// unsigned long int
00ULL; // COMPLIANT - unsigned, but uses the suffix correctly
017777777777ULL; // COMPLIANT - unsigned, but uses the suffix correctly
020000000000ULL; // COMPLIANT - unsigned, but uses the suffix correctly
040000000000ULL; // COMPLIANT - unsigned, but uses the suffix correctly
0777777777777777777777ULL; // COMPLIANT - unsigned, but uses the suffix
// correctly
01000000000000000000000ULL; // COMPLIANT - unsigned, but uses the suffix
// correctly
}
void test_binary_constants() {
0b0; // COMPLIANT - uses signed int
0b1111111111111111111111111111111; // COMPLIANT - max value held by signed int
0b10000000000000000000000000000000; // NON_COMPLIANT - larger than max signed
// int, so will be unsigned int
0b100000000000000000000000000000000; // COMPLIANT - larger than unsigned int,
// but smaller than long int
0b111111111111111111111111111111111111111111111111111111111111111; // COMPLIANT
// - max
// long int
0b1000000000000000000000000000000000000000000000000000000000000000; // NON_COMPLIANT
// -
// larger
// than
// long
// int, so
// will be
// unsigned
// long
// int
0b0U; // COMPLIANT - unsigned, but uses the suffix correctly
0b1111111111111111111111111111111U; // COMPLIANT - unsigned, but uses the
// suffix correctly
0b10000000000000000000000000000000U; // COMPLIANT - unsigned, but uses the
// suffix correctly
0b100000000000000000000000000000000U; // COMPLIANT - unsigned, but uses the
// suffix correctly
0b111111111111111111111111111111111111111111111111111111111111111U; // COMPLIANT
// -
// unsigned,
// but
// uses
// the
// suffix
// correctly
0b1000000000000000000000000000000000000000000000000000000000000000U; // COMPLIANT
// -
// unsigned,
// but
// uses
// the
// suffix
// correctly
// Use of the `l` suffix
0b0l; // COMPLIANT - uses signed long
0b1111111111111111111111111111111l; // COMPLIANT - uses signed long
0b10000000000000000000000000000000l; // COMPLIANT - uses signed long
0b100000000000000000000000000000000l; // COMPLIANT - uses signed long
0b111111111111111111111111111111111111111111111111111111111111111l; // COMPLIANT
// - max
// long
// int
0b1000000000000000000000000000000000000000000000000000000000000000l; // NON_COMPLIANT
// -
// larger
// than
// long
// int,
// so
// will
// be
// unsigned
// long
// int
0b0Ul; // COMPLIANT - unsigned, but uses the suffix correctly
0b1111111111111111111111111111111Ul; // COMPLIANT - unsigned, but uses the
// suffix correctly
0b10000000000000000000000000000000Ul; // COMPLIANT - unsigned, but uses the
// suffix correctly
0b100000000000000000000000000000000Ul; // COMPLIANT - unsigned, but uses the
// suffix correctly
0b111111111111111111111111111111111111111111111111111111111111111Ul; // COMPLIANT
// -
// unsigned,
// but
// uses
// the
// suffix
// correctly
0b1000000000000000000000000000000000000000000000000000000000000000Ul; // COMPLIANT
// -
// unsigned,
// but
// uses
// the
// suffix
// correctly
// Use of the `L` suffix
0b0L; // COMPLIANT - uses signed long
0b1111111111111111111111111111111L; // COMPLIANT - uses signed long
0b10000000000000000000000000000000L; // COMPLIANT - uses signed long
0b100000000000000000000000000000000L; // COMPLIANT - uses signed long
0b111111111111111111111111111111111111111111111111111111111111111L; // COMPLIANT
// -
// COMPLIANT
// - uses
// signed
// long
0b1000000000000000000000000000000000000000000000000000000000000000L; // NON_COMPLIANT
// -
// larger
// than
// long
// int,
// so
// will
// be
// unsigned
// long
// int
0b0UL; // COMPLIANT - unsigned, but uses the suffix correctly
0b1111111111111111111111111111111UL; // COMPLIANT - unsigned, but uses the
// suffix correctly
0b10000000000000000000000000000000UL; // COMPLIANT - unsigned, but uses the
// suffix correctly
0b100000000000000000000000000000000UL; // COMPLIANT - unsigned, but uses the
// suffix correctly
0b111111111111111111111111111111111111111111111111111111111111111UL; // COMPLIANT
// -
// unsigned,
// but
// uses
// the
// suffix
// correctly
0b1000000000000000000000000000000000000000000000000000000000000000UL; // COMPLIANT
// -
// unsigned,
// but
// uses
// the
// suffix
// correctly
// Use of the `ll` suffix
0b0ll; // COMPLIANT - uses signed long long
0b1111111111111111111111111111111ll; // COMPLIANT - uses signed long long
0b10000000000000000000000000000000ll; // COMPLIANT - uses signed long long
0b100000000000000000000000000000000ll; // COMPLIANT - uses signed long long
0b111111111111111111111111111111111111111111111111111111111111111ll; // COMPLIANT
// - max
// long
// int
0b1000000000000000000000000000000000000000000000000000000000000000ll; // NON_COMPLIANT
// -
// larger
// than
// long
// int,
// so
// will
// be
// unsigned
// long
// int
0b0Ull; // COMPLIANT - unsigned, but uses the suffix correctly
0b1111111111111111111111111111111Ull; // COMPLIANT - unsigned, but uses the
// suffix correctly
0b10000000000000000000000000000000Ull; // COMPLIANT - unsigned, but uses the
// suffix correctly
0b100000000000000000000000000000000Ull; // COMPLIANT - unsigned, but uses the
// suffix correctly
0b111111111111111111111111111111111111111111111111111111111111111Ull; // COMPLIANT
// -
// unsigned,
// but
// uses
// the
// suffix
// correctly
0b1000000000000000000000000000000000000000000000000000000000000000Ull; // COMPLIANT
// -
// unsigned,
// but
// uses
// the
// suffix
// correctly
// Use of the `LL` suffix
00LL; // COMPLIANT - uses signed long long
0b1111111111111111111111111111111LL; // COMPLIANT - uses signed long long
0b10000000000000000000000000000000LL; // COMPLIANT - uses signed long long
0b100000000000000000000000000000000LL; // COMPLIANT - uses signed long long
0b111111111111111111111111111111111111111111111111111111111111111LL; // COMPLIANT
// - max
// long
// int
0b1000000000000000000000000000000000000000000000000000000000000000LL; // NON_COMPLIANT
// -
// larger
// than
// long
// int,
// so
// will
// be
// unsigned
// long
// int
00ULL; // COMPLIANT - unsigned, but uses the suffix correctly
0b1111111111111111111111111111111ULL; // COMPLIANT - unsigned, but uses the
// suffix correctly
0b10000000000000000000000000000000ULL; // COMPLIANT - unsigned, but uses the
// suffix correctly
0b100000000000000000000000000000000ULL; // COMPLIANT - unsigned, but uses the
// suffix correctly
0b111111111111111111111111111111111111111111111111111111111111111ULL; // COMPLIANT
// -
// unsigned,
// but
// uses
// the
// suffix
// correctly
0b1000000000000000000000000000000000000000000000000000000000000000ULL; // COMPLIANT
// -
// unsigned,
// but
// uses
// the
// suffix
// correctly
}
#define COMPLIANT_VAL 0x80000000U
#define NON_COMPLIANT_VAL 0x80000000
void test_macro() {
COMPLIANT_VAL; // COMPLIANT
NON_COMPLIANT_VAL; // NON_COMPLIANT[FALSE_NEGATIVE] - cannot determine suffix
// in macro expansions
}