Debian Codegraph @

clang/test/SemaCXX/windows-Wpadded.cpp

raw
1 // RUN: %clang_cc1 -triple x86_64-windows-msvc -fsyntax-only -verify -Wpadded %s
2 // RUN: %clang_cc1 -triple x86_64-linux-gnu -fsyntax-only -verify -Wpadded %s
3
4 struct __attribute__((ms_struct)) Foo { // expected-warning {{padding size of 'Foo' with 3 bytes to alignment boundary}}
5 int b : 1;
6 char a; // expected-warning {{padding struct 'Foo' with 31 bits to align 'a'}}
7 };
8
9 struct __attribute__((ms_struct)) AlignedStruct { // expected-warning {{padding size of 'AlignedStruct' with 4 bytes to alignment boundary}}
10 char c;
11 alignas(8) int i; // expected-warning {{padding struct 'AlignedStruct' with 7 bytes to align 'i'}}
12 };
13
14
15 struct Base {
16 int b;
17 };
18
19 struct Derived : public Base { // expected-warning {{padding size of 'Derived' with 3 bytes to alignment boundary}}
20 char c;
21 };
22
23 union __attribute__((ms_struct)) Union {
24 char c;
25 long long u;
26 };
27
28 struct __attribute__((ms_struct)) StructWithUnion { // expected-warning {{padding size of 'StructWithUnion' with 6 bytes to alignment boundary}}
29 char c;
30 int : 0;
31 Union t; // expected-warning {{padding struct 'StructWithUnion' with 7 bytes to align 't'}}
32 short i;
33 };
34
35 struct __attribute__((ms_struct)) EmptyStruct {};
36
37 struct __attribute__((ms_struct)) AlignedMemberStruct { // expected-warning {{padding size of 'AlignedMemberStruct' with 28 bytes to alignment boundary}}
38 alignas(32) int x;
39 };
40
41 struct alignas(32) __attribute__((ms_struct)) AlignedNonEmptyStruct { // expected-warning {{padding size of 'AlignedNonEmptyStruct' with 28 bytes to alignment boundary}}
42 int x;
43 };
44
45
46 struct alignas(16) __attribute__((ms_struct)) AlignedEmptyStruct {}; // expected-warning {{padding size of 'AlignedEmptyStruct' with 15 bytes to alignment boundary}}
47
48 int main() {
49 Foo f;
50 AlignedStruct a;
51 Derived d;
52 StructWithUnion swu;
53 EmptyStruct e;
54 AlignedNonEmptyStruct anes;
55 AlignedMemberStruct ams;
56 AlignedEmptyStruct aes;
57 }