Skip to content

Commit e53acac

Browse files
authored
[clang] Properly check for -mms-bitfields in Sema/struct-packed-align.c (#172337)
Before #71148, providing only `-triple=x86_64-windows-gnu` to cc1 did not set `-mms-bitfields` (`-fms-layout-compatibility=microsoft`). Therefore, MS-compatible layout was only triggered in true MSVC targets. This is not the case now, so we should only check if we are compiling for Windows to test to determine if MS layout will be used. The change of behavior is harmless as it only affects direct invocations of cc1.
1 parent b988555 commit e53acac

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

clang/test/Sema/struct-packed-align.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// RUN: %clang_cc1 %s -fsyntax-only -verify
22
// RUN: %clang_cc1 %s -fsyntax-only -triple=x86_64-windows-coff -verify
3+
// RUN: %clang_cc1 %s -fsyntax-only -triple=x86_64-windows-gnu -verify
34
// RUN: %clang_cc1 %s -fsyntax-only -triple=x86_64-scei-ps4 -verify
45
// RUN: %clang_cc1 %s -fsyntax-only -triple=x86_64-sie-ps5 -verify
56

@@ -131,7 +132,7 @@ struct nS {
131132
nt start_lba;
132133
};
133134

134-
#if defined(_WIN32) && !defined(__declspec) // _MSC_VER is unavailable in cc1.
135+
#if defined(_WIN32)
135136
// Alignment doesn't affect packing in MS mode.
136137
extern int n1[sizeof(struct nS) == 16 ? 1 : -1];
137138
extern int n2[__alignof(struct nS) == 8 ? 1 : -1];
@@ -159,7 +160,7 @@ struct packed_chars {
159160
char f : 4, g : 8, h : 8, i : 8;
160161
};
161162

162-
#if (defined(_WIN32) || defined(__SCE__)) && !defined(__declspec) // _MSC_VER is unavailable in cc1.
163+
#if defined(_WIN32) || defined(__SCE__)
163164
// On Windows clang uses MSVC compatible layout in this case.
164165
//
165166
// Additionally, test for pre-r254596 clang behavior on the PS4/PS5 targets.

0 commit comments

Comments
 (0)