1f4a2713aSLionel Sambuc // RUN: %clang_cc1 %s -triple i386-unknown-unknown -emit-llvm -O1 -relaxed-aliasing -fstrict-enums -std=c++11 -o - | FileCheck %s
2f4a2713aSLionel Sambuc // RUN: %clang_cc1 %s -triple i386-unknown-unknown -emit-llvm -O1 -relaxed-aliasing -std=c++11 -o - | FileCheck --check-prefix=NO-STRICT-ENUMS %s
3f4a2713aSLionel Sambuc
f(bool * x)4f4a2713aSLionel Sambuc bool f(bool *x) {
5f4a2713aSLionel Sambuc return *x;
6f4a2713aSLionel Sambuc }
7f4a2713aSLionel Sambuc // CHECK-LABEL: define zeroext i1 @_Z1fPb
8f4a2713aSLionel Sambuc // CHECK: load i8* %{{[^ ]*}}, align 1, !range [[RANGE_i8_0_2:![^ ]*]]
9f4a2713aSLionel Sambuc
10f4a2713aSLionel Sambuc // Only enum-tests follow. Ensure that after the bool test, no further range
11f4a2713aSLionel Sambuc // metadata shows up when strict enums are disabled.
12f4a2713aSLionel Sambuc // NO-STRICT-ENUMS-LABEL: define zeroext i1 @_Z1fPb
13f4a2713aSLionel Sambuc // NO-STRICT-ENUMS: load i8* %{{[^ ]*}}, align 1, !range
14f4a2713aSLionel Sambuc // NO-STRICT-ENUMS-NOT: !range
15f4a2713aSLionel Sambuc
16f4a2713aSLionel Sambuc enum e1 { };
g1(e1 * x)17f4a2713aSLionel Sambuc e1 g1(e1 *x) {
18f4a2713aSLionel Sambuc return *x;
19f4a2713aSLionel Sambuc }
20f4a2713aSLionel Sambuc // CHECK-LABEL: define i32 @_Z2g1P2e1
21*0a6a1f1dSLionel Sambuc // CHECK: ret i32 0
22f4a2713aSLionel Sambuc
23f4a2713aSLionel Sambuc enum e2 { e2_a = 0 };
g2(e2 * x)24f4a2713aSLionel Sambuc e2 g2(e2 *x) {
25f4a2713aSLionel Sambuc return *x;
26f4a2713aSLionel Sambuc }
27f4a2713aSLionel Sambuc // CHECK-LABEL: define i32 @_Z2g2P2e2
28*0a6a1f1dSLionel Sambuc // CHECK: ret i32 0
29f4a2713aSLionel Sambuc
30f4a2713aSLionel Sambuc enum e3 { e3_a = 16 };
g3(e3 * x)31f4a2713aSLionel Sambuc e3 g3(e3 *x) {
32f4a2713aSLionel Sambuc return *x;
33f4a2713aSLionel Sambuc }
34f4a2713aSLionel Sambuc // CHECK-LABEL: define i32 @_Z2g3P2e3
35f4a2713aSLionel Sambuc // CHECK: load i32* %x, align 4, !range [[RANGE_i32_0_32:![^ ]*]]
36f4a2713aSLionel Sambuc
37f4a2713aSLionel Sambuc enum e4 { e4_a = -16};
g4(e4 * x)38f4a2713aSLionel Sambuc e4 g4(e4 *x) {
39f4a2713aSLionel Sambuc return *x;
40f4a2713aSLionel Sambuc }
41f4a2713aSLionel Sambuc // CHECK-LABEL: define i32 @_Z2g4P2e4
42f4a2713aSLionel Sambuc // CHECK: load i32* %x, align 4, !range [[RANGE_i32_m16_16:![^ ]*]]
43f4a2713aSLionel Sambuc
44f4a2713aSLionel Sambuc enum e5 { e5_a = -16, e5_b = 16};
g5(e5 * x)45f4a2713aSLionel Sambuc e5 g5(e5 *x) {
46f4a2713aSLionel Sambuc return *x;
47f4a2713aSLionel Sambuc }
48f4a2713aSLionel Sambuc // CHECK-LABEL: define i32 @_Z2g5P2e5
49f4a2713aSLionel Sambuc // CHECK: load i32* %x, align 4, !range [[RANGE_i32_m32_32:![^ ]*]]
50f4a2713aSLionel Sambuc
51f4a2713aSLionel Sambuc enum e6 { e6_a = -1 };
g6(e6 * x)52f4a2713aSLionel Sambuc e6 g6(e6 *x) {
53f4a2713aSLionel Sambuc return *x;
54f4a2713aSLionel Sambuc }
55f4a2713aSLionel Sambuc // CHECK-LABEL: define i32 @_Z2g6P2e6
56f4a2713aSLionel Sambuc // CHECK: load i32* %x, align 4, !range [[RANGE_i32_m1_1:![^ ]*]]
57f4a2713aSLionel Sambuc
58f4a2713aSLionel Sambuc enum e7 { e7_a = -16, e7_b = 2};
g7(e7 * x)59f4a2713aSLionel Sambuc e7 g7(e7 *x) {
60f4a2713aSLionel Sambuc return *x;
61f4a2713aSLionel Sambuc }
62f4a2713aSLionel Sambuc // CHECK-LABEL: define i32 @_Z2g7P2e7
63f4a2713aSLionel Sambuc // CHECK: load i32* %x, align 4, !range [[RANGE_i32_m16_16]]
64f4a2713aSLionel Sambuc
65f4a2713aSLionel Sambuc enum e8 { e8_a = -17};
g8(e8 * x)66f4a2713aSLionel Sambuc e8 g8(e8 *x) {
67f4a2713aSLionel Sambuc return *x;
68f4a2713aSLionel Sambuc }
69f4a2713aSLionel Sambuc // CHECK-LABEL: define i32 @_Z2g8P2e8
70f4a2713aSLionel Sambuc // CHECK: load i32* %x, align 4, !range [[RANGE_i32_m32_32:![^ ]*]]
71f4a2713aSLionel Sambuc
72f4a2713aSLionel Sambuc enum e9 { e9_a = 17};
g9(e9 * x)73f4a2713aSLionel Sambuc e9 g9(e9 *x) {
74f4a2713aSLionel Sambuc return *x;
75f4a2713aSLionel Sambuc }
76f4a2713aSLionel Sambuc // CHECK-LABEL: define i32 @_Z2g9P2e9
77f4a2713aSLionel Sambuc // CHECK: load i32* %x, align 4, !range [[RANGE_i32_0_32]]
78f4a2713aSLionel Sambuc
79f4a2713aSLionel Sambuc enum e10 { e10_a = -16, e10_b = 32};
g10(e10 * x)80f4a2713aSLionel Sambuc e10 g10(e10 *x) {
81f4a2713aSLionel Sambuc return *x;
82f4a2713aSLionel Sambuc }
83f4a2713aSLionel Sambuc // CHECK-LABEL: define i32 @_Z3g10P3e10
84f4a2713aSLionel Sambuc // CHECK: load i32* %x, align 4, !range [[RANGE_i32_m64_64:![^ ]*]]
85f4a2713aSLionel Sambuc
86f4a2713aSLionel Sambuc enum e11 {e11_a = 4294967296 };
g11(enum e11 * x)87f4a2713aSLionel Sambuc enum e11 g11(enum e11 *x) {
88f4a2713aSLionel Sambuc return *x;
89f4a2713aSLionel Sambuc }
90f4a2713aSLionel Sambuc // CHECK-LABEL: define i64 @_Z3g11P3e11
91f4a2713aSLionel Sambuc // CHECK: load i64* %x, align {{[84]}}, !range [[RANGE_i64_0_2pow33:![^ ]*]]
92f4a2713aSLionel Sambuc
93f4a2713aSLionel Sambuc enum e12 {e12_a = 9223372036854775808U };
g12(enum e12 * x)94f4a2713aSLionel Sambuc enum e12 g12(enum e12 *x) {
95f4a2713aSLionel Sambuc return *x;
96f4a2713aSLionel Sambuc }
97f4a2713aSLionel Sambuc // CHECK-LABEL: define i64 @_Z3g12P3e12
98f4a2713aSLionel Sambuc // CHECK: load i64* %x, align {{[84]}}
99f4a2713aSLionel Sambuc // CHECK-NOT: range
100f4a2713aSLionel Sambuc // CHECK: ret
101f4a2713aSLionel Sambuc
102f4a2713aSLionel Sambuc enum e13 : char {e13_a = -1 };
g13(e13 * x)103f4a2713aSLionel Sambuc e13 g13(e13 *x) {
104f4a2713aSLionel Sambuc return *x;
105f4a2713aSLionel Sambuc }
106f4a2713aSLionel Sambuc // CHECK-LABEL: define signext i8 @_Z3g13P3e13
107f4a2713aSLionel Sambuc // CHECK: load i8* %x, align 1
108f4a2713aSLionel Sambuc // CHECK-NOT: range
109f4a2713aSLionel Sambuc // CHECK: ret
110f4a2713aSLionel Sambuc
111f4a2713aSLionel Sambuc enum class e14 {e14_a = 1};
g14(e14 * x)112f4a2713aSLionel Sambuc e14 g14(e14 *x) {
113f4a2713aSLionel Sambuc return *x;
114f4a2713aSLionel Sambuc }
115f4a2713aSLionel Sambuc // CHECK-LABEL: define i32 @_Z3g14P3e14
116f4a2713aSLionel Sambuc // CHECK: load i32* %x, align 4
117f4a2713aSLionel Sambuc // CHECK-NOT: range
118f4a2713aSLionel Sambuc // CHECK: ret
119f4a2713aSLionel Sambuc
120f4a2713aSLionel Sambuc enum e15 { e15_a = 2147483648 };
g15(e15 * x)121f4a2713aSLionel Sambuc e15 g15(e15 *x) {
122f4a2713aSLionel Sambuc return *x;
123f4a2713aSLionel Sambuc }
124f4a2713aSLionel Sambuc // CHECK-LABEL: define i32 @_Z3g15P3e15
125f4a2713aSLionel Sambuc // CHECK: load i32* %x, align 4
126f4a2713aSLionel Sambuc // CHECK-NOT: range
127f4a2713aSLionel Sambuc // CHECK: ret
128f4a2713aSLionel Sambuc
129f4a2713aSLionel Sambuc enum e16 { e16_a = -2147483648 };
g16(e16 * x)130f4a2713aSLionel Sambuc e16 g16(e16 *x) {
131f4a2713aSLionel Sambuc return *x;
132f4a2713aSLionel Sambuc }
133f4a2713aSLionel Sambuc // CHECK-LABEL: define i32 @_Z3g16P3e16
134f4a2713aSLionel Sambuc // CHECK: load i32* %x, align 4
135f4a2713aSLionel Sambuc // CHECK-NOT: range
136f4a2713aSLionel Sambuc // CHECK: ret
137f4a2713aSLionel Sambuc
138f4a2713aSLionel Sambuc
139*0a6a1f1dSLionel Sambuc // CHECK: [[RANGE_i8_0_2]] = !{i8 0, i8 2}
140*0a6a1f1dSLionel Sambuc // CHECK: [[RANGE_i32_0_32]] = !{i32 0, i32 32}
141*0a6a1f1dSLionel Sambuc // CHECK: [[RANGE_i32_m16_16]] = !{i32 -16, i32 16}
142*0a6a1f1dSLionel Sambuc // CHECK: [[RANGE_i32_m32_32]] = !{i32 -32, i32 32}
143*0a6a1f1dSLionel Sambuc // CHECK: [[RANGE_i32_m1_1]] = !{i32 -1, i32 1}
144*0a6a1f1dSLionel Sambuc // CHECK: [[RANGE_i32_m64_64]] = !{i32 -64, i32 64}
145*0a6a1f1dSLionel Sambuc // CHECK: [[RANGE_i64_0_2pow33]] = !{i64 0, i64 8589934592}
146