diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index 197b3692b8a18..ce0b293928992 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -574,6 +574,12 @@ Attribute Changes in Clang - Clang now disallows the use of attributes after the namespace name. (#GH121407) +- On targets with Itanium C++ ABI, Clang now supports ``[[gnu:gcc_struct]]`` + with the behavior similar to one existing in GCC. In particular, whenever + ``-mms-bitfields`` command line option is provided (or if Microsoft-compatible + structure layout is default on the target), ``[[gnu::gcc_struct]]`` requests + the compiler to follow Itanium rules for the layout of an annotated structure. + Improvements to Clang's diagnostics ----------------------------------- diff --git a/clang/include/clang/AST/ASTContext.h b/clang/include/clang/AST/ASTContext.h index 0e07c5d6ce8fb..b3545f5811865 100644 --- a/clang/include/clang/AST/ASTContext.h +++ b/clang/include/clang/AST/ASTContext.h @@ -2610,6 +2610,14 @@ class ASTContext : public RefCountedBase { /// runtime, such as those using the Itanium C++ ABI. CharUnits getExnObjectAlignment() const; + /// Return whether getASTRecordLayout will use MicrosoftRecordLayoutBuilder + /// or ItaniumRecordLayoutBuilder. + bool isMicrosoftLayout() const; + + /// Return whether unannotated records are treated as if they have + /// [[gnu::ms_struct]]. + bool defaultsToMsStruct() const; + /// Get or compute information about the layout of the specified /// record (struct/union/class) \p D, which indicates its size and field /// position information. diff --git a/clang/include/clang/Basic/Attr.td b/clang/include/clang/Basic/Attr.td index 5039c20d8b73b..a8b30e195144f 100644 --- a/clang/include/clang/Basic/Attr.td +++ b/clang/include/clang/Basic/Attr.td @@ -4130,7 +4130,14 @@ def CFGuard : InheritableAttr, TargetSpecificAttr { def MSStruct : InheritableAttr { let Spellings = [GCC<"ms_struct">]; let Subjects = SubjectList<[Record]>; - let Documentation = [Undocumented]; + let Documentation = [MSStructDocs]; + let SimpleHandler = 1; +} + +def GCCStruct : InheritableAttr { + let Spellings = [GCC<"gcc_struct">]; + let Subjects = SubjectList<[Record]>; + let Documentation = [MSStructDocs]; // Covers this attribute too. let SimpleHandler = 1; } diff --git a/clang/include/clang/Basic/AttrDocs.td b/clang/include/clang/Basic/AttrDocs.td index 506fe38eb882b..4161dad37dab9 100644 --- a/clang/include/clang/Basic/AttrDocs.td +++ b/clang/include/clang/Basic/AttrDocs.td @@ -8943,3 +8943,19 @@ Declares that a function potentially allocates heap memory, and prevents any pot of ``nonallocating`` by the compiler. }]; } + +def MSStructDocs : Documentation { + let Category = DocCatDecl; + let Content = [{ +The ``ms_struct`` and ``gcc_struct`` attributes request the compiler to enter a +special record layout compatibility mode which mimics the layout of Microsoft or +Itanium C++ ABI respectively. Obviously, if the current C++ ABI matches the +requested ABI, the attribute does nothing. However, if it does not, annotated +structure or class is laid out in a special compatibility mode, which slightly +changes offsets for fields and bit-fields. The intention is to match the layout +of the requested ABI for structures which only use C features. + +Note that the default behavior can be controlled by ``-mms-bitfields`` and +``-mno-ms-bitfields`` switches and via ``#pragma ms_struct``. + }]; +} diff --git a/clang/include/clang/Basic/DiagnosticASTKinds.td b/clang/include/clang/Basic/DiagnosticASTKinds.td index ab432606edbc4..133527205bf12 100644 --- a/clang/include/clang/Basic/DiagnosticASTKinds.td +++ b/clang/include/clang/Basic/DiagnosticASTKinds.td @@ -997,6 +997,9 @@ def warn_npot_ms_struct : Warning< "data types with sizes that aren't a power of two">, DefaultError, InGroup; +def err_itanium_layout_unimplemented : Error< + "Itanium-compatible layout for the Microsoft C++ ABI is not yet supported">; + // -Wpadded-bitfield def warn_padded_struct_bitfield : Warning< "padding %select{struct|interface|class}0 %1 with %2 " diff --git a/clang/include/clang/Basic/LangOptions.def b/clang/include/clang/Basic/LangOptions.def index 3b833240e5b68..aeefc90f197fd 100644 --- a/clang/include/clang/Basic/LangOptions.def +++ b/clang/include/clang/Basic/LangOptions.def @@ -151,7 +151,8 @@ LANGOPT(AssumeNothrowExceptionDtor , 1, 0, "Assume exception object's destructor LANGOPT(TraditionalCPP , 1, 0, "traditional CPP emulation") LANGOPT(RTTI , 1, 1, "run-time type information") LANGOPT(RTTIData , 1, 1, "emit run-time type information data") -LANGOPT(MSBitfields , 1, 0, "Microsoft-compatible structure layout") +ENUM_LANGOPT(LayoutCompatibility, LayoutCompatibilityKind, 2, + LayoutCompatibilityKind::Default, "Microsoft-compatible structure layout") LANGOPT(MSVolatile , 1, 0, "Microsoft-compatible volatile loads and stores") LANGOPT(Freestanding, 1, 0, "freestanding implementation") LANGOPT(NoBuiltin , 1, 0, "disable builtin functions") diff --git a/clang/include/clang/Basic/LangOptions.h b/clang/include/clang/Basic/LangOptions.h index 949c8f5d448bc..104c96f642ec4 100644 --- a/clang/include/clang/Basic/LangOptions.h +++ b/clang/include/clang/Basic/LangOptions.h @@ -479,6 +479,16 @@ class LangOptionsBase { None, }; + enum class LayoutCompatibilityKind { + /// Use default layout rules of the target. + Default = 0, + /// Use Itanium rules for bit-field layout and fundamental types alignment. + Itanium = 1, + /// Use Microsoft C++ ABI rules for bit-field layout and fundamental types + /// alignment. + Microsoft = 2, + }; + // Define simple language options (with no accessors). #define LANGOPT(Name, Bits, Default, Description) unsigned Name : Bits; #define ENUM_LANGOPT(Name, Type, Bits, Default, Description) diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td index 80360216c9503..8967c550d1ef5 100644 --- a/clang/include/clang/Driver/Options.td +++ b/clang/include/clang/Driver/Options.td @@ -4861,9 +4861,7 @@ def mmacos_version_min_EQ : Joined<["-"], "mmacos-version-min=">, def : Joined<["-"], "mmacosx-version-min=">, Group, Alias; def mms_bitfields : Flag<["-"], "mms-bitfields">, Group, - Visibility<[ClangOption, CC1Option]>, - HelpText<"Set the default structure layout to be compatible with the Microsoft compiler standard">, - MarshallingInfoFlag>; + HelpText<"Set the default structure layout to be compatible with the Microsoft compiler standard">; def moutline : Flag<["-"], "moutline">, Group, Visibility<[ClangOption, CC1Option]>, HelpText<"Enable function outlining (AArch64 only)">; @@ -4872,6 +4870,12 @@ def mno_outline : Flag<["-"], "mno-outline">, Group, HelpText<"Disable function outlining (AArch64 only)">; def mno_ms_bitfields : Flag<["-"], "mno-ms-bitfields">, Group, HelpText<"Do not set the default structure layout to be compatible with the Microsoft compiler standard">; +def fms_layout_compatibility_EQ : Joined<["-"], "fms-layout-compatibility=">, + Visibility<[CC1Option]>, + HelpText<"Structure layout compatibility with Microsoft C++ ABI">, + Values<"default,itanium,microsoft">, + NormalizedValues<["Default", "Itanium", "Microsoft"]>, NormalizedValuesScope<"LangOptions::LayoutCompatibilityKind">, + MarshallingInfoEnum, "Default">; def mskip_rax_setup : Flag<["-"], "mskip-rax-setup">, Group, Visibility<[ClangOption, CC1Option]>, HelpText<"Skip setting up RAX register when passing variable arguments (x86 only)">, diff --git a/clang/lib/AST/Decl.cpp b/clang/lib/AST/Decl.cpp index 31749e46458d6..7ca48c0b8a85b 100644 --- a/clang/lib/AST/Decl.cpp +++ b/clang/lib/AST/Decl.cpp @@ -5125,7 +5125,14 @@ void RecordDecl::completeDefinition() { /// This which can be turned on with an attribute, pragma, or the /// -mms-bitfields command-line option. bool RecordDecl::isMsStruct(const ASTContext &C) const { - return hasAttr() || C.getLangOpts().MSBitfields == 1; + if (hasAttr()) + return false; + if (hasAttr()) + return true; + auto LayoutCompatibility = C.getLangOpts().getLayoutCompatibility(); + if (LayoutCompatibility == LangOptions::LayoutCompatibilityKind::Default) + return C.defaultsToMsStruct(); + return LayoutCompatibility == LangOptions::LayoutCompatibilityKind::Microsoft; } void RecordDecl::reorderDecls(const SmallVectorImpl &Decls) { diff --git a/clang/lib/AST/RecordLayoutBuilder.cpp b/clang/lib/AST/RecordLayoutBuilder.cpp index ae6d299024c6d..8ff6248d03570 100644 --- a/clang/lib/AST/RecordLayoutBuilder.cpp +++ b/clang/lib/AST/RecordLayoutBuilder.cpp @@ -2443,15 +2443,6 @@ static bool mustSkipTailPadding(TargetCXXABI ABI, const CXXRecordDecl *RD) { llvm_unreachable("bad tail-padding use kind"); } -static bool isMsLayout(const ASTContext &Context) { - // Check if it's CUDA device compilation; ensure layout consistency with host. - if (Context.getLangOpts().CUDA && Context.getLangOpts().CUDAIsDevice && - Context.getAuxTargetInfo()) - return Context.getAuxTargetInfo()->getCXXABI().isMicrosoft(); - - return Context.getTargetInfo().getCXXABI().isMicrosoft(); -} - // This section contains an implementation of struct layout that is, up to the // included tests, compatible with cl.exe (2013). The layout produced is // significantly different than those produced by the Itanium ABI. Here we note @@ -2793,6 +2784,13 @@ void MicrosoftRecordLayoutBuilder::initializeLayout(const RecordDecl *RD) { UseExternalLayout = Source->layoutRecordType( RD, External.Size, External.Align, External.FieldOffsets, External.BaseOffsets, External.VirtualBaseOffsets); + + if (!RD->isMsStruct(Context)) { + auto Location = RD->getLocation(); + if (Location.isValid()) + Context.getDiagnostics().Report(Location, + diag::err_itanium_layout_unimplemented); + } } void @@ -3314,6 +3312,19 @@ void MicrosoftRecordLayoutBuilder::computeVtorDispSet( } } +bool ASTContext::isMicrosoftLayout() const { + // Check if it's CUDA device compilation; ensure layout consistency with host. + if (getLangOpts().CUDA && getLangOpts().CUDAIsDevice && getAuxTargetInfo()) + return getAuxTargetInfo()->getCXXABI().isMicrosoft(); + + return getTargetInfo().getCXXABI().isMicrosoft(); +} + +bool ASTContext::defaultsToMsStruct() const { + return isMicrosoftLayout() || + getTargetInfo().getTriple().isWindowsGNUEnvironment(); +} + /// getASTRecordLayout - Get or compute information about the layout of the /// specified record (struct/union/class), which indicates its size and field /// position information. @@ -3342,7 +3353,7 @@ ASTContext::getASTRecordLayout(const RecordDecl *D) const { const ASTRecordLayout *NewEntry = nullptr; - if (isMsLayout(*this)) { + if (isMicrosoftLayout()) { if (const auto *RD = dyn_cast(D)) { EmptySubobjectMap EmptySubobjects(*this, RD); MicrosoftRecordLayoutBuilder Builder(*this, &EmptySubobjects); @@ -3618,7 +3629,7 @@ static void DumpRecordLayout(raw_ostream &OS, const RecordDecl *RD, bool HasOwnVBPtr = Layout.hasOwnVBPtr(); // Vtable pointer. - if (CXXRD->isDynamicClass() && !PrimaryBase && !isMsLayout(C)) { + if (CXXRD->isDynamicClass() && !PrimaryBase && !C.isMicrosoftLayout()) { PrintOffset(OS, Offset, IndentLevel); OS << '(' << *RD << " vtable pointer)\n"; } else if (HasOwnVFPtr) { @@ -3716,7 +3727,7 @@ static void DumpRecordLayout(raw_ostream &OS, const RecordDecl *RD, PrintIndentNoOffset(OS, IndentLevel - 1); OS << "[sizeof=" << Layout.getSize().getQuantity(); - if (CXXRD && !isMsLayout(C)) + if (CXXRD && !C.isMicrosoftLayout()) OS << ", dsize=" << Layout.getDataSize().getQuantity(); OS << ", align=" << Layout.getAlignment().getQuantity(); if (C.getTargetInfo().defaultsToAIXPowerAlignment()) @@ -3755,7 +3766,7 @@ void ASTContext::DumpRecordLayout(const RecordDecl *RD, raw_ostream &OS, OS << "\nLayout: "; OS << "defaultsToAIXPowerAlignment()) diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp index 33f08cf28feca..23c37a72a8083 100644 --- a/clang/lib/Driver/ToolChains/Clang.cpp +++ b/clang/lib/Driver/ToolChains/Clang.cpp @@ -6113,9 +6113,13 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA, if (KernelOrKext && RawTriple.isOSDarwin()) CmdArgs.push_back("-fforbid-guard-variables"); - if (Args.hasFlag(options::OPT_mms_bitfields, options::OPT_mno_ms_bitfields, - Triple.isWindowsGNUEnvironment())) { - CmdArgs.push_back("-mms-bitfields"); + if (Args.hasArg(options::OPT_mms_bitfields) || + Args.hasArg(options::OPT_mno_ms_bitfields)) { + if (Args.hasFlag(options::OPT_mms_bitfields, options::OPT_mno_ms_bitfields, + false)) + CmdArgs.push_back("-fms-layout-compatibility=microsoft"); + else + CmdArgs.push_back("-fms-layout-compatibility=itanium"); } if (Triple.isWindowsGNUEnvironment()) { diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp index 5b7275c316f74..ae03aaa7b562b 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -18336,9 +18336,7 @@ ExprResult Sema::VerifyBitField(SourceLocation FieldLoc, // ABI. bool CStdConstraintViolation = BitfieldIsOverwide && !getLangOpts().CPlusPlus; - bool MSBitfieldViolation = - Value.ugt(TypeStorageSize) && - (IsMsStruct || Context.getTargetInfo().getCXXABI().isMicrosoft()); + bool MSBitfieldViolation = Value.ugt(TypeStorageSize) && IsMsStruct; if (CStdConstraintViolation || MSBitfieldViolation) { unsigned DiagWidth = CStdConstraintViolation ? TypeWidth : TypeStorageSize; diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp index c4bee44f5ec04..8bb12fb5e947a 100644 --- a/clang/lib/Sema/SemaDeclCXX.cpp +++ b/clang/lib/Sema/SemaDeclCXX.cpp @@ -7131,20 +7131,27 @@ void Sema::CheckCompletedCXXClass(Scope *S, CXXRecordDecl *Record) { CheckCompletedMemberFunction(MD); } - // ms_struct is a request to use the same ABI rules as MSVC. Check - // whether this class uses any C++ features that are implemented - // completely differently in MSVC, and if so, emit a diagnostic. - // That diagnostic defaults to an error, but we allow projects to - // map it down to a warning (or ignore it). It's a fairly common - // practice among users of the ms_struct pragma to mass-annotate - // headers, sweeping up a bunch of types that the project doesn't - // really rely on MSVC-compatible layout for. We must therefore - // support "ms_struct except for C++ stuff" as a secondary ABI. + // {ms,gcc}_struct is a request to change ABI rules to either follow + // Microsoft or Itanium C++ ABI. However, even if these attributes are + // present, we do not layout classes following foreign ABI rules, but + // instead enter a special "compatibility mode", which only changes + // alignments of fundamental types and layout of bit fields. + // Check whether this class uses any C++ features that are implemented + // completely differently in the requested ABI, and if so, emit a + // diagnostic. That diagnostic defaults to an error, but we allow + // projects to map it down to a warning (or ignore it). It's a fairly + // common practice among users of the ms_struct pragma to + // mass-annotate headers, sweeping up a bunch of types that the + // project doesn't really rely on MSVC-compatible layout for. We must + // therefore support "ms_struct except for C++ stuff" as a secondary + // ABI. // Don't emit this diagnostic if the feature was enabled as a // language option (as opposed to via a pragma or attribute), as // the option -mms-bitfields otherwise essentially makes it impossible // to build C++ code, unless this diagnostic is turned off. - if (Record->isMsStruct(Context) && !Context.getLangOpts().MSBitfields && + if (Context.getLangOpts().getLayoutCompatibility() == + LangOptions::LayoutCompatibilityKind::Default && + Record->isMsStruct(Context) != Context.defaultsToMsStruct() && (Record->isPolymorphic() || Record->getNumBases())) { Diag(Record->getLocation(), diag::warn_cxx_ms_struct); } diff --git a/clang/test/CodeGen/gcc_struct-msvc-todo-1.c b/clang/test/CodeGen/gcc_struct-msvc-todo-1.c new file mode 100644 index 0000000000000..0bd097f0765cc --- /dev/null +++ b/clang/test/CodeGen/gcc_struct-msvc-todo-1.c @@ -0,0 +1,6 @@ +// RUN: %clang_cc1 -emit-llvm-only -triple x86_64-pc-windows-msvc -verify %s + +// expected-error@+1 {{Itanium-compatible layout for the Microsoft C++ ABI is not yet supported}} +struct { + int a; +} __attribute__((gcc_struct)) t1; diff --git a/clang/test/CodeGen/gcc_struct-msvc-todo-2.c b/clang/test/CodeGen/gcc_struct-msvc-todo-2.c new file mode 100644 index 0000000000000..048bf43d31c2a --- /dev/null +++ b/clang/test/CodeGen/gcc_struct-msvc-todo-2.c @@ -0,0 +1,6 @@ +// RUN: %clang_cc1 -emit-llvm-only -triple x86_64-pc-windows-msvc -fms-layout-compatibility=itanium -verify %s + +// expected-error@+1 {{Itanium-compatible layout for the Microsoft C++ ABI is not yet supported}} +struct { + int a; +} t1; diff --git a/clang/test/CodeGen/gcc_struct.c b/clang/test/CodeGen/gcc_struct.c new file mode 100644 index 0000000000000..57ea58de7cfe2 --- /dev/null +++ b/clang/test/CodeGen/gcc_struct.c @@ -0,0 +1,18 @@ +// RUN: %clang_cc1 -emit-llvm-only -triple x86_64-pc-linux-gnu %s +// RUN: %clang_cc1 -emit-llvm-only -triple x86_64-pc-linux-gnu -fms-layout-compatibility=microsoft %s +// RUN: %clang_cc1 -emit-llvm-only -triple x86_64-pc-windows-gnu %s +// RUN: %clang_cc1 -emit-llvm-only -triple x86_64-pc-windows-gnu -fms-layout-compatibility=itanium %s + +struct { + int a : 24; + char b : 8; +} __attribute__((gcc_struct)) t1; +_Static_assert(sizeof(t1) == 4, ""); + +#pragma ms_struct on +struct { + int a : 24; + char b : 8; +} __attribute__((gcc_struct)) t2; +_Static_assert(sizeof(t2) == 4, ""); +#pragma ms_struct off diff --git a/clang/test/CodeGen/mingw-long-double.c b/clang/test/CodeGen/mingw-long-double.c index 0fc8f01509682..ccd3b9c3ff10b 100644 --- a/clang/test/CodeGen/mingw-long-double.c +++ b/clang/test/CodeGen/mingw-long-double.c @@ -1,6 +1,6 @@ // RUN: %clang_cc1 -triple i686-windows-gnu -emit-llvm -o - %s \ // RUN: | FileCheck %s --check-prefix=GNU32 -// RUN: %clang_cc1 -triple i686-windows-gnu -emit-llvm -o - %s -mms-bitfields \ +// RUN: %clang_cc1 -triple i686-windows-gnu -emit-llvm -o - %s -fms-layout-compatibility=microsoft \ // RUN: | FileCheck %s --check-prefix=GNU32 // RUN: %clang_cc1 -triple x86_64-windows-gnu -emit-llvm -o - %s \ // RUN: | FileCheck %s --check-prefix=GNU64 diff --git a/clang/test/CodeGen/mms-bitfields.c b/clang/test/CodeGen/mms-bitfields.c index 2ccce326c7131..8d3b403b7e7be 100644 --- a/clang/test/CodeGen/mms-bitfields.c +++ b/clang/test/CodeGen/mms-bitfields.c @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -triple i386-apple-darwin10 -mms-bitfields -emit-llvm %s -o - | FileCheck %s +// RUN: %clang_cc1 -triple i386-apple-darwin10 -fms-layout-compatibility=microsoft -emit-llvm %s -o - | FileCheck %s struct s1 { int f32; diff --git a/clang/test/Driver/ms-bitfields.c b/clang/test/Driver/ms-bitfields.c index d5a3656b3d110..acd1bdc9c0ac9 100644 --- a/clang/test/Driver/ms-bitfields.c +++ b/clang/test/Driver/ms-bitfields.c @@ -1,8 +1,15 @@ -// RUN: %clang -### --target=x86_64-linux-gnu %s 2>&1 | FileCheck %s -check-prefix=NO-MSBITFIELDS -// RUN: %clang -### --target=x86_64-windows-gnu %s 2>&1 | FileCheck %s -check-prefix=MSBITFIELDS -// RUN: %clang -### -mno-ms-bitfields -mms-bitfields %s 2>&1 | FileCheck %s -check-prefix=MSBITFIELDS -// RUN: %clang -### -mms-bitfields -mno-ms-bitfields %s 2>&1 | FileCheck %s -check-prefix=NO-MSBITFIELDS +// RUN: %clang -### --target=x86_64-linux-gnu %s 2>&1 | FileCheck %s -check-prefix=DEFAULT-LAYOUT +// RUN: %clang -### --target=x86_64-windows-gnu %s 2>&1 | FileCheck %s -check-prefix=DEFAULT-LAYOUT +// RUN: %clang -### --target=x86_64-windows-msvc %s 2>&1 | FileCheck %s -check-prefix=DEFAULT-LAYOUT +// RUN: %clang -### -mms-bitfields %s 2>&1 | FileCheck %s -check-prefix=MICROSOFT-LAYOUT +// RUN: %clang -### -mno-ms-bitfields %s 2>&1 | FileCheck %s -check-prefix=ITANIUM-LAYOUT +// RUN: %clang -### -mno-ms-bitfields -mms-bitfields %s 2>&1 | FileCheck %s -check-prefix=MICROSOFT-LAYOUT +// RUN: %clang -### -mms-bitfields -mno-ms-bitfields %s 2>&1 | FileCheck %s -check-prefix=ITANIUM-LAYOUT -// MSBITFIELDS: -mms-bitfields -// NO-MSBITFIELDS-NOT: -mms-bitfields +// DEFAULT-LAYOUT-NOT: -fms-layout-compatibility=itanium +// DEFAULT-LAYOUT-NOT: -fms-layout-compatibility=microsoft +// MICROSOFT-LAYOUT: -fms-layout-compatibility=microsoft +// MICROSOFT-LAYOUT-NOT: -fms-layout-compatibility=itanium +// ITANIUM-LAYOUT: -fms-layout-compatibility=itanium +// ITANIUM-LAYOUT-NOT: -fms-layout-compatibility=microsoft diff --git a/clang/test/Layout/itanium-union-bitfield.cpp b/clang/test/Layout/itanium-union-bitfield.cpp index febfc46dfee54..34f501f4b569a 100644 --- a/clang/test/Layout/itanium-union-bitfield.cpp +++ b/clang/test/Layout/itanium-union-bitfield.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -emit-llvm-only -triple %itanium_abi_triple -fdump-record-layouts %s 2>/dev/null \ +// RUN: %clang_cc1 -emit-llvm-only -triple %itanium_abi_triple -fms-layout-compatibility=itanium -fdump-record-layouts %s 2>/dev/null \ // RUN: | FileCheck %s // On z/OS, a bit-field has single byte alignment. Add aligned(4) on z/OS so the union has diff --git a/clang/test/Misc/pragma-attribute-supported-attributes-list.test b/clang/test/Misc/pragma-attribute-supported-attributes-list.test index 4a6ac39da18ad..f9f7e228dfa28 100644 --- a/clang/test/Misc/pragma-attribute-supported-attributes-list.test +++ b/clang/test/Misc/pragma-attribute-supported-attributes-list.test @@ -83,6 +83,7 @@ // CHECK-NEXT: FlagEnum (SubjectMatchRule_enum) // CHECK-NEXT: Flatten (SubjectMatchRule_function) // CHECK-NEXT: FunctionReturnThunks (SubjectMatchRule_function) +// CHECK-NEXT: GCCStruct (SubjectMatchRule_record) // CHECK-NEXT: GNUInline (SubjectMatchRule_function) // CHECK-NEXT: HIPManaged (SubjectMatchRule_variable) // CHECK-NEXT: Hot (SubjectMatchRule_function) diff --git a/clang/test/Sema/mms-bitfields.c b/clang/test/Sema/mms-bitfields.c index cee5b0669d252..d0a67a4a3d793 100644 --- a/clang/test/Sema/mms-bitfields.c +++ b/clang/test/Sema/mms-bitfields.c @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -mms-bitfields -fsyntax-only -verify -triple x86_64-apple-darwin9 %s +// RUN: %clang_cc1 -fms-layout-compatibility=microsoft -fsyntax-only -verify -triple x86_64-apple-darwin9 %s // expected-no-diagnostics // The -mms-bitfields commandline parameter should behave the same diff --git a/clang/test/SemaCXX/ms_struct.cpp b/clang/test/SemaCXX/ms_struct.cpp index 995e424d1f876..29d29e4fd6fdc 100644 --- a/clang/test/SemaCXX/ms_struct.cpp +++ b/clang/test/SemaCXX/ms_struct.cpp @@ -1,7 +1,7 @@ // RUN: %clang_cc1 -fsyntax-only -DTEST_FOR_WARNING -Wno-error=incompatible-ms-struct -verify -triple i686-apple-darwin9 -std=c++11 %s // RUN: %clang_cc1 -fsyntax-only -DTEST_FOR_WARNING -Wno-error=incompatible-ms-struct -verify -triple armv7-apple-darwin9 -std=c++11 %s // RUN: %clang_cc1 -fsyntax-only -DTEST_FOR_ERROR -verify -triple armv7-apple-darwin9 -std=c++11 %s -// RUN: %clang_cc1 -fsyntax-only -DNO_PRAGMA -mms-bitfields -verify -triple armv7-apple-darwin9 -std=c++11 %s +// RUN: %clang_cc1 -fsyntax-only -DNO_PRAGMA -fms-layout-compatibility=microsoft -verify -triple armv7-apple-darwin9 -std=c++11 %s #ifndef NO_PRAGMA #pragma ms_struct on diff --git a/clang/test/SemaCXX/ms_wide_bitfield.cpp b/clang/test/SemaCXX/ms_wide_bitfield.cpp index a5b7a433c7c4c..eccfd90f0faf0 100644 --- a/clang/test/SemaCXX/ms_wide_bitfield.cpp +++ b/clang/test/SemaCXX/ms_wide_bitfield.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -fno-rtti -triple i686-pc-win32 -fdump-record-layouts -fsyntax-only -mms-bitfields -verify %s 2>&1 +// RUN: %clang_cc1 -fno-rtti -triple i686-pc-win32 -fdump-record-layouts -fsyntax-only -fms-layout-compatibility=microsoft -verify %s 2>&1 struct A { char a : 9; // expected-error{{width of bit-field 'a' (9 bits) exceeds the size of its type (8 bits)}} diff --git a/clang/utils/TableGen/ClangDiagnosticsEmitter.cpp b/clang/utils/TableGen/ClangDiagnosticsEmitter.cpp index 72b3468dac486..4cd738f692d1d 100644 --- a/clang/utils/TableGen/ClangDiagnosticsEmitter.cpp +++ b/clang/utils/TableGen/ClangDiagnosticsEmitter.cpp @@ -1210,6 +1210,7 @@ static bool isExemptAtStart(StringRef Text) { .Case("Fuchsia", true) .Case("GNUstep", true) .Case("IBOutletCollection", true) + .Case("Itanium", true) .Case("Microsoft", true) .Case("Neon", true) .StartsWith("NSInvocation", true) // NSInvocation, NSInvocation's