| 1 |
// RUN: %clang_cc1 -std=c2x -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 (void)' |
| 4 |
void func(void) { |
| 5 |
// Ensure that we calculate the correct type from the literal suffix. |
| 6 |
|
| 7 |
// Note: 0wb 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:27> col:27 zero_wb 'typeof (0wb)':'_BitInt(2)' |
| 11 |
typedef __typeof__(0wb) zero_wb; |
| 12 |
// CHECK: TypedefDecl 0x{{[^ ]*}} <col:3, col:28> col:28 neg_zero_wb 'typeof (-0wb)':'_BitInt(2)' |
| 13 |
typedef __typeof__(-0wb) neg_zero_wb; |
| 14 |
// CHECK: TypedefDecl 0x{{[^ ]*}} <col:3, col:27> col:27 one_wb 'typeof (1wb)':'_BitInt(2)' |
| 15 |
typedef __typeof__(1wb) one_wb; |
| 16 |
// CHECK: TypedefDecl 0x{{[^ ]*}} <col:3, col:28> col:28 neg_one_wb 'typeof (-1wb)':'_BitInt(2)' |
| 17 |
typedef __typeof__(-1wb) neg_one_wb; |
| 18 |
|
| 19 |
// CHECK: TypedefDecl 0x{{[^ ]*}} <col:3, col:28> col:28 zero_uwb 'typeof (0uwb)':'unsigned _BitInt(1)' |
| 20 |
typedef __typeof__(0uwb) zero_uwb; |
| 21 |
// CHECK: TypedefDecl 0x{{[^ ]*}} <col:3, col:29> col:29 neg_zero_uwb 'typeof (-0uwb)':'unsigned _BitInt(1)' |
| 22 |
typedef __typeof__(-0uwb) neg_zero_uwb; |
| 23 |
// CHECK: TypedefDecl 0x{{[^ ]*}} <col:3, col:28> col:28 one_uwb 'typeof (1uwb)':'unsigned _BitInt(1)' |
| 24 |
typedef __typeof__(1uwb) 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:47> col:47 huge_uwb 'typeof (18446744073709551616uwb)':'unsigned _BitInt(65)' |
| 29 |
typedef __typeof__(18446744073709551616uwb) huge_uwb; |
| 30 |
// CHECK: TypedefDecl 0x{{[^ ]*}} <col:3, col:46> col:46 huge_wb 'typeof (18446744073709551616wb)':'_BitInt(66)' |
| 31 |
typedef __typeof__(18446744073709551616wb) huge_wb; |
| 32 |
} |
| 33 |
|
| 34 |
// Test the examples from the paper. |
| 35 |
// CHECK: FunctionDecl 0x{{[^ ]*}} <{{.*}}:[[@LINE+1]]:1, line:{{[0-9]*}}:1> line:[[@LINE+1]]:6 from_paper 'void (void)' |
| 36 |
void from_paper(void) { |
| 37 |
// CHECK: TypedefDecl 0x{{[^ ]*}} <col:3, col:28> col:28 neg_three_wb 'typeof (-3wb)':'_BitInt(3)' |
| 38 |
typedef __typeof__(-3wb) neg_three_wb; |
| 39 |
// CHECK: TypedefDecl 0x{{[^ ]*}} <col:3, col:30> col:30 neg_three_hex_wb 'typeof (-3wb)':'_BitInt(3)' |
| 40 |
typedef __typeof__(-0x3wb) neg_three_hex_wb; |
| 41 |
// CHECK: TypedefDecl 0x{{[^ ]*}} <col:3, col:27> col:27 three_wb 'typeof (3wb)':'_BitInt(3)' |
| 42 |
typedef __typeof__(3wb) three_wb; |
| 43 |
// CHECK: TypedefDecl 0x{{[^ ]*}} <col:3, col:28> col:28 three_uwb 'typeof (3uwb)':'unsigned _BitInt(2)' |
| 44 |
typedef __typeof__(3uwb) three_uwb; |
| 45 |
// CHECK: TypedefDecl 0x{{[^ ]*}} <col:3, col:29> col:29 neg_three_uwb 'typeof (-3uwb)':'unsigned _BitInt(2)' |
| 46 |
typedef __typeof__(-3uwb) neg_three_uwb; |
| 47 |
} |