1 // RUN: %clang_cc1 -triple x86_64-gnu-linux -O3 -disable-llvm-passes -emit-llvm -o - %s | FileCheck %s --check-prefixes=CHECK
2 // RUN: %clang_cc1 -triple x86_64-windows-pc -O3 -disable-llvm-passes -emit-llvm -o - %s | FileCheck %s --check-prefixes=CHECK
3 
4 
5 void GenericTest(_ExtInt(3) a, unsigned _ExtInt(3) b, _ExtInt(4) c) {
6   // CHECK: define {{.*}}void @GenericTest
7   int which = _Generic(a, _ExtInt(3): 1, unsigned _ExtInt(3) : 2, _ExtInt(4) : 3);
8   // CHECK: store i32 1
9   int which2 = _Generic(b, _ExtInt(3): 1, unsigned _ExtInt(3) : 2, _ExtInt(4) : 3);
10   // CHECK: store i32 2
11   int which3 = _Generic(c, _ExtInt(3): 1, unsigned _ExtInt(3) : 2, _ExtInt(4) : 3);
12   // CHECK: store i32 3
13 }
14 
15 void VLATest(_ExtInt(3) A, _ExtInt(99) B, _ExtInt(123456) C) {
16   // CHECK: define {{.*}}void @VLATest
17   int AR1[A];
18   // CHECK: %[[A:.+]] = zext i3 %{{.+}} to i64
19   // CHECK: %[[VLA1:.+]] = alloca i32, i64 %[[A]]
20   int AR2[B];
21   // CHECK: %[[B:.+]] = trunc i99 %{{.+}} to i64
22   // CHECK: %[[VLA2:.+]] = alloca i32, i64 %[[B]]
23   int AR3[C];
24   // CHECK: %[[C:.+]] = trunc i123456 %{{.+}} to i64
25   // CHECK: %[[VLA3:.+]] = alloca i32, i64 %[[C]]
26 }
27 
28 struct S {
29   _ExtInt(17) A;
30   _ExtInt(16777200) B;
31   _ExtInt(17) C;
32 };
33 
34 void OffsetOfTest() {
35   // CHECK: define {{.*}}void @OffsetOfTest
36   int A = __builtin_offsetof(struct S,A);
37   // CHECK: store i32 0, i32* %{{.+}}
38   int B = __builtin_offsetof(struct S,B);
39   // CHECK: store i32 8, i32* %{{.+}}
40   int C = __builtin_offsetof(struct S,C);
41   // CHECK: store i32 2097160, i32* %{{.+}}
42 }
43 
44 
45