Skip to content

Commit ae08106

Browse files
committed
[PP-EXT] Add functions to a test file
1 parent d8e7ddf commit ae08106

File tree

1 file changed

+24
-5
lines changed

1 file changed

+24
-5
lines changed

clang/test/CodeGen/pp-generalization.c

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,15 @@
1111
// CHECK-LL: struct Generalization definition
1212
// CHECK-LL: load 'double'
1313
// CHECK-LL: __pp_specialization_type 'int'
14-
// CHECK-LL: %struct.__pp_struct_Generalization__Base1 = type { %struct.Generalization, %struct.Base1 }
15-
// CHECK-LL: %struct.Generalization = type { double, i32 }
14+
1615
// CHECK-LL: %struct.Base1 = type { i32 }
17-
// CHECK-LL: %struct.__pp_struct_Generalization__Base2 = type { %struct.Generalization, %struct.Base2 }
1816
// CHECK-LL: %struct.Base2 = type { i32 }
19-
// CHECK-LL: double @check_gen(ptr noundef byval(%struct.__pp_struct_Generalization__Base1) align 8 %gb)
17+
// CHECK-LL: %struct.Generalization = type { double, i32 }
18+
// CHECK-LL: %struct.__pp_struct_Generalization__Base1 = type { %struct.Generalization, %struct.Base1 }
19+
// CHECK-LL: %struct.__pp_struct_Generalization__Base2 = type { %struct.Generalization, %struct.Base2 }
20+
21+
// CHECK-LL: double @check_gen_b1(ptr noundef byval(%struct.__pp_struct_Generalization__Base1) align 8 %gb)
22+
// CHECK-LL: double @check_gen_b2(ptr noundef byval(%struct.__pp_struct_Generalization__Base2) align 8 %gb)
2023

2124
// CHECK-AST: |-RecordDecl {{.*}} struct Base1 definition
2225
// CHECK-AST-NEXT:| `-FieldDecl {{.*}} i 'int'
@@ -36,15 +39,31 @@ struct Base1 { int i; };
3639
struct Base2 { int j; };
3740
struct Generalization { double load; } < Base1, Base2 >;
3841

39-
double check_gen (struct Generalization<Base1> gb) { return gb.__pp_head.load; }
42+
int get_b1_field(struct Base1 b) { return b.i; }
43+
int get_b2_field(struct Base2 b) { return b.j; }
4044
double foo (struct Generalization g) { return g.load; }
4145

4246
int get_tag1 (struct __pp_struct_Generalization__Base1 b)
4347
{ return b.__pp_head.__pp_specialization_type; }
4448
int get_tag2 (struct __pp_struct_Generalization__Base2 b)
4549
{ return b.__pp_head.__pp_specialization_type; }
50+
4651
struct Generalization get_gen1 (struct __pp_struct_Generalization__Base1 b) { return b.__pp_head; }
4752
struct Generalization get_gen2 (struct __pp_struct_Generalization__Base2 b) { return b.__pp_head; }
4853

4954
struct Base1 get_b1 (struct __pp_struct_Generalization__Base1 b) { return b.__pp_tail; }
5055
struct Base2 get_b2 (struct __pp_struct_Generalization__Base2 b) { return b.__pp_tail; }
56+
57+
double check_gen_b1 (struct Generalization<Base1> gb) { return gb.__pp_head.load; }
58+
double check_gen_b2 (struct Generalization<Base2> gb) { return gb.__pp_head.load; }
59+
60+
int get_spec_field1 (struct Generalization<Base1> gb) { return gb.__pp_tail.i; }
61+
int get_spec_field2 (struct Generalization<Base2> gb) { return gb.__pp_tail.j; }
62+
63+
int test_vars() {
64+
struct Generalization<Base1> gb1;
65+
gb1.__pp_tail.i = 3;
66+
struct Generalization<Base2> gb2;
67+
gb2.__pp_tail.j = 5;
68+
return get_spec_field1(gb1) + get_spec_field2(gb2);
69+
}

0 commit comments

Comments
 (0)