Skip to content

Commit ec85ec2

Browse files
committed
test(clang-cl): anonymous bitfield, union, alignas, derived padding
1 parent a259c2b commit ec85ec2

5 files changed

+58
-1
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// RUN: %clang_cl -Wpadded -Wno-msvc-not-found -fsyntax-only -- %s 2>&1 | FileCheck -check-prefix=WARN %s
2+
// RUN: %clang -Wpadded -fsyntax-only -- %s 2>&1 | FileCheck -check-prefix=WARN %s
3+
4+
struct __attribute__((ms_struct)) AlignedStruct {
5+
char c;
6+
alignas(8) int i;
7+
};
8+
9+
int main() {AlignedStruct s;}
10+
11+
// WARN: warning: padding struct 'AlignedStruct' with 7 bytes to align 'i'
12+
// WARN: warning: padding size of 'AlignedStruct' with 4 bytes to alignment boundary
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// RUN: %clang_cl -Wpadded -Wno-msvc-not-found -fsyntax-only -- %s 2>&1 | FileCheck -check-prefix=WARN %s
2+
3+
struct __attribute__((ms_struct)) BitfieldStruct {
4+
char c : 1;
5+
int : 0;
6+
char i;
7+
};
8+
9+
int main() {BitfieldStruct s;}
10+
11+
// WARN: warning: padding struct 'BitfieldStruct' with 31 bits to align anonymous bit-field
12+
// WARN: warning: padding size of 'BitfieldStruct' with 3 bytes to alignment boundary
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// RUN: %clang_cl -Wpadded -Wno-msvc-not-found -fsyntax-only -- %s 2>&1 | FileCheck -check-prefix=WARN %s
2+
// RUN: %clang -Wpadded -fsyntax-only -- %s 2>&1 | FileCheck -check-prefix=WARN %s
3+
4+
struct Base {
5+
int b;
6+
};
7+
8+
struct Derived : public Base {
9+
char c;
10+
};
11+
12+
int main() {Derived d;}
13+
// WARN: warning: padding size of 'Derived' with 3 bytes to alignment boundary
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// RUN: %clang_cl -Wpadded -Wno-msvc-not-found -fsyntax-only -- %s 2>&1 | FileCheck -check-prefix=WARN %s
2+
// RUN: %clang -Wpadded -fsyntax-only -- %s 2>&1 | FileCheck -check-prefix=WARN %s
3+
4+
union __attribute__((ms_struct)) Union {
5+
char c;
6+
long long u;
7+
};
8+
9+
struct __attribute__((ms_struct)) StructWithUnion {
10+
char c;
11+
int : 0;
12+
Union t;
13+
short i;
14+
};
15+
16+
int main() { StructWithUnion s; }
17+
18+
// WARN: warning: padding struct 'StructWithUnion' with 7 bytes to align 't'
19+
// WARN: warning: padding size of 'StructWithUnion' with 6 bytes to alignment boundary

clang/test/Driver/windows-Wpadded.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// RUN: %clang_cl -Wpadded -Wno-msvc-not-found -fsyntax-only -- %s 2>&1 | FileCheck -check-prefix=WARN %s
2+
// RUN: %clang -Wpadded -fsyntax-only -- %s 2>&1 | FileCheck -check-prefix=WARN %s
23

3-
struct Foo {
4+
struct __attribute__((ms_struct)) Foo {
45
int b : 1;
56
char a;
67
};

0 commit comments

Comments
 (0)