llvm-project
78 строк · 2.1 Кб
1// RUN: %clang_cc1 -triple x86_64-pc-windows-msvc -emit-pch -o %t.pch %s
2// RUN: %clang_cc1 -triple x86_64-pc-windows-msvc -fdelayed-template-parsing -emit-pch -o %t.delayed.pch %s
3// RUN: %clang_cc1 -triple x86_64-pc-windows-msvc -DMAIN_FILE \
4// RUN: -include-pch %t.pch \
5// RUN: -emit-llvm -verify -o - %s | FileCheck %s
6// RUN: %clang_cc1 -triple x86_64-pc-windows-msvc -DMAIN_FILE -fdelayed-template-parsing \
7// RUN: -include-pch %t.delayed.pch \
8// RUN: -emit-llvm -verify -o - %s | FileCheck %s
9
10#ifndef MAIN_FILE
11
12extern "C" void consume(int b);
13
14template <int I>
15void function() {
16#pragma pack(push, 1)
17struct packedAt1 {
18char a;
19unsigned long long b;
20char c;
21unsigned long long d;
22// 18 bytes total
23};
24#pragma pack(push, slot1, 2)
25struct packedAt2 {
26char a; // +1 byte of padding
27unsigned long long b;
28char c; // +1 byte of padding
29unsigned long long d;
30// 20 bytes total
31};
32#pragma pack(push, 4)
33struct packedAt4 {
34char a; // +3 bytes of padding
35unsigned long long b;
36char c; // +3 bytes of padding
37unsigned long long d;
38// 24 bytes total
39};
40#pragma pack(push, 16)
41struct packedAt16 {
42char a; // +7 bytes of padding
43unsigned long long b;
44char c; // +7 bytes of padding
45unsigned long long d;
46// 32 bytes total
47};
48#pragma pack(pop, slot1) // This should return packing to 1 (established before push(slot1))
49struct packedAfterPopBackTo1 {
50char a;
51unsigned long long b;
52char c;
53unsigned long long d;
54};
55#pragma pack(pop)
56
57consume(sizeof(packedAt1)); // 18
58consume(sizeof(packedAt2)); // 20
59consume(sizeof(packedAt4)); // 24
60consume(sizeof(packedAt16)); // 32
61consume(sizeof(packedAfterPopBackTo1)); // 18 again
62}
63
64#else
65
66// CHECK-LABEL: define linkonce_odr dso_local void @"??$function@$0A@@@YAXXZ"(
67// CHECK: call void @consume(i32 noundef 18)
68// CHECK-NEXT: call void @consume(i32 noundef 20)
69// CHECK-NEXT: call void @consume(i32 noundef 24)
70// CHECK-NEXT: call void @consume(i32 noundef 32)
71// CHECK-NEXT: call void @consume(i32 noundef 18)
72void foo() {
73function<0>();
74}
75
76// expected-no-diagnostics
77
78#endif
79