Skip to content

Commit dea03c8

Browse files
committed
fixup! Add test for gcc_struct
1 parent 77f9935 commit dea03c8

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

clang/lib/AST/Decl.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5125,10 +5125,10 @@ void RecordDecl::completeDefinition() {
51255125
/// This which can be turned on with an attribute, pragma, or the
51265126
/// -mms-bitfields command-line option.
51275127
bool RecordDecl::isMsStruct(const ASTContext &C) const {
5128-
if (hasAttr<MSStructAttr>())
5129-
return true;
51305128
if (hasAttr<GCCStructAttr>())
51315129
return false;
5130+
if (hasAttr<MSStructAttr>())
5131+
return true;
51325132
auto LayoutCompatibility = C.getLangOpts().getLayoutCompatibility();
51335133
if (LayoutCompatibility == LangOptions::LayoutCompatibilityKind::Default)
51345134
return C.defaultsToMsStruct();

clang/test/CodeGen/gcc_struct.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// RUN: %clang_cc1 -emit-llvm-only -triple x86_64-pc-linux-gnu %s
2+
// RUN: %clang_cc1 -emit-llvm-only -triple x86_64-pc-linux-gnu -fms-layout-compatibility=microsoft %s
3+
// RUN: %clang_cc1 -emit-llvm-only -triple x86_64-pc-windows-gnu %s
4+
// RUN: %clang_cc1 -emit-llvm-only -triple x86_64-pc-windows-gnu -fms-layout-compatibility=itanium %s
5+
6+
struct {
7+
int a : 24;
8+
char b : 8;
9+
} __attribute__((gcc_struct)) t1;
10+
static int a1[(sizeof(t1) == 4) - 1];
11+
12+
#pragma ms_struct on
13+
struct {
14+
int a : 24;
15+
char b : 8;
16+
} __attribute__((gcc_struct)) t2;
17+
static int a2[(sizeof(t2) == 4) - 1];
18+
#pragma ms_struct off

0 commit comments

Comments
 (0)