[clang] Implement lifetime analysis for lifetime_capture_by(X) (#115921)
[llvm-project.git] / clang / test / PCH / delayed-template-with-pragma-pack.cpp
blobcee33685bd8d570477f9cf29f20527cac0dff1d1
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
10 #ifndef MAIN_FILE
12 extern "C" void consume(int b);
14 template <int I>
15 void function() {
16 #pragma pack(push, 1)
17 struct packedAt1 {
18 char a;
19 unsigned long long b;
20 char c;
21 unsigned long long d;
22 // 18 bytes total
24 #pragma pack(push, slot1, 2)
25 struct packedAt2 {
26 char a; // +1 byte of padding
27 unsigned long long b;
28 char c; // +1 byte of padding
29 unsigned long long d;
30 // 20 bytes total
32 #pragma pack(push, 4)
33 struct packedAt4 {
34 char a; // +3 bytes of padding
35 unsigned long long b;
36 char c; // +3 bytes of padding
37 unsigned long long d;
38 // 24 bytes total
40 #pragma pack(push, 16)
41 struct packedAt16 {
42 char a; // +7 bytes of padding
43 unsigned long long b;
44 char c; // +7 bytes of padding
45 unsigned long long d;
46 // 32 bytes total
48 #pragma pack(pop, slot1) // This should return packing to 1 (established before push(slot1))
49 struct packedAfterPopBackTo1 {
50 char a;
51 unsigned long long b;
52 char c;
53 unsigned long long d;
55 #pragma pack(pop)
57 consume(sizeof(packedAt1)); // 18
58 consume(sizeof(packedAt2)); // 20
59 consume(sizeof(packedAt4)); // 24
60 consume(sizeof(packedAt16)); // 32
61 consume(sizeof(packedAfterPopBackTo1)); // 18 again
64 #else
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)
72 void foo() {
73 function<0>();
76 // expected-no-diagnostics
78 #endif