1 // RUN: %clang_cc1 -triple x86_64-unknown-unknown -emit-llvm %s -o - | FileCheck %s
2
3 // Test checks that 'mode' attribute is handled correctly with enums, i. e. code
4 // 1. "typedef enum { A } __attribute__((mode(HI))) T;" is accepted,
5 // 2. "enum X __attribute__((mode(QI))) var;" forms a complete integer type.
6
main()7 int main() {
8 // CHECK: [[X1:%.+]] = alloca i8
9 enum { A1, B1 } __attribute__((mode(QI))) x1 = A1;
10
11 // CHECK: [[X2:%.+]] = alloca i16
12 enum { A2, B2 } x2 __attribute__((mode(HI))) = B2;
13
14 // CHECK: [[X3:%.+]] = alloca i32
15 typedef enum { A3, B3 } __attribute__((mode(SI))) T3;
16 T3 x3 = A3;
17
18 // CHECK: [[X4:%.+]] = alloca i64
19 typedef enum { A4, B4 } T4 __attribute__((mode(DI)));
20 T4 x4 = B4;
21
22 // CHECK: [[X5:%.+]] = alloca i8
23 typedef enum __attribute__((mode(QI))) { A5, B5 } T5;
24 T5 x5 = A5;
25
26 // CHECK: [[X6:%.+]] = alloca i8
27 typedef enum X __attribute__((mode(QI))) T6;
28 T6 x6;
29
30 // CHECK: [[X7:%.+]] = alloca i128
31 enum { A7, B7 } __attribute__((mode(TI))) x7 = A7;
32
33 // CHECK: [[X8:%.+]] = alloca i8
34 enum __attribute__((mode(QI))) { A8, B8 } x8 = B8;
35
36 // CHECK: store i8 0, i8* [[X1]]
37 // CHECK: store i16 1, i16* [[X2]]
38 // CHECK: store i32 0, i32* [[X3]]
39 // CHECK: store i64 1, i64* [[X4]]
40 // CHECK: store i8 0, i8* [[X5]]
41 // CHECK: store i128 0, i128* [[X7]]
42 // CHECK: store i8 1, i8* [[X8]]
43
44 return x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8;
45 }
46