xref: /llvm-project/clang/test/AST/bitint-suffix.cpp (revision ca1f1c957232b05d6529916bcd769ae1c57ff935)
1 // RUN: %clang_cc1 -ast-dump -Wno-unused %s | FileCheck --strict-whitespace %s
2 
3 // CHECK: FunctionDecl 0x{{[^ ]*}} <{{.*}}:[[@LINE+1]]:1, line:{{[0-9]*}}:1> line:[[@LINE+1]]:6 func 'void ()'
func()4 void func() {
5   // Ensure that we calculate the correct type from the literal suffix.
6 
7   // Note: 0__wb should create an _BitInt(2) because a signed bit-precise
8   // integer requires one bit for the sign and one bit for the value,
9   // at a minimum.
10   // CHECK: TypedefDecl 0x{{[^ ]*}} <col:3, col:29> col:29 zero_wb 'typeof (0wb)':'_BitInt(2)'
11   typedef __typeof__(0__wb) zero_wb;
12   // CHECK: TypedefDecl 0x{{[^ ]*}} <col:3, col:30> col:30 neg_zero_wb 'typeof (-0wb)':'_BitInt(2)'
13   typedef __typeof__(-0__wb) neg_zero_wb;
14   // CHECK: TypedefDecl 0x{{[^ ]*}} <col:3, col:29> col:29 one_wb 'typeof (1wb)':'_BitInt(2)'
15   typedef __typeof__(1__wb) one_wb;
16   // CHECK: TypedefDecl 0x{{[^ ]*}} <col:3, col:30> col:30 neg_one_wb 'typeof (-1wb)':'_BitInt(2)'
17   typedef __typeof__(-1__wb) neg_one_wb;
18 
19   // CHECK: TypedefDecl 0x{{[^ ]*}} <col:3, col:30> col:30 zero_uwb 'typeof (0uwb)':'unsigned _BitInt(1)'
20   typedef __typeof__(0__uwb) zero_uwb;
21   // CHECK: TypedefDecl 0x{{[^ ]*}} <col:3, col:31> col:31 neg_zero_uwb 'typeof (-0uwb)':'unsigned _BitInt(1)'
22   typedef __typeof__(-0__uwb) neg_zero_uwb;
23   // CHECK: TypedefDecl 0x{{[^ ]*}} <col:3, col:30> col:30 one_uwb 'typeof (1uwb)':'unsigned _BitInt(1)'
24   typedef __typeof__(1__uwb) one_uwb;
25 
26   // Try a value that is too large to fit in [u]intmax_t.
27 
28   // CHECK: TypedefDecl 0x{{[^ ]*}} <col:3, col:49> col:49 huge_uwb 'typeof (18446744073709551616uwb)':'unsigned _BitInt(65)'
29   typedef __typeof__(18446744073709551616__uwb) huge_uwb;
30   // CHECK: TypedefDecl 0x{{[^ ]*}} <col:3, col:48> col:48 huge_wb 'typeof (18446744073709551616wb)':'_BitInt(66)'
31   typedef __typeof__(18446744073709551616__wb) huge_wb;
32 }
33