Author: David Blaikie Date: 2022-10-13T21:13:19Z New Revision: 9363071303ec59bc9e0d9b989f08390b37e3f5e4
URL: https://github.com/llvm/llvm-project/commit/9363071303ec59bc9e0d9b989f08390b37e3f5e4 DIFF: https://github.com/llvm/llvm-project/commit/9363071303ec59bc9e0d9b989f08390b37e3f5e4.diff LOG: Move GCC-compatible pod-packing change to v16/old behavior available at v15 and below Change matches D126334/e59f648d698e since this change got punted from v15 too. Added: Modified: clang/docs/ReleaseNotes.rst clang/include/clang/Basic/LangOptions.h clang/lib/AST/RecordLayoutBuilder.cpp clang/test/SemaCXX/class-layout.cpp Removed: ################################################################################ diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index b036764803007..2a81877f27b71 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -524,6 +524,12 @@ OpenCL C Language Changes in Clang ABI Changes in Clang -------------------- +- GCC doesn't pack non-POD members in packed structs unless the packed + attribute is also specified on the member. Clang historically did perform + such packing. Clang now matches the gcc behavior (except on Darwin and PS4). + You can switch back to the old ABI behavior with the flag: + ``-fclang-abi-compat=15.0``. + OpenMP Support in Clang ----------------------- diff --git a/clang/include/clang/Basic/LangOptions.h b/clang/include/clang/Basic/LangOptions.h index 4cac4c221d8b5..cfa98329ce24a 100644 --- a/clang/include/clang/Basic/LangOptions.h +++ b/clang/include/clang/Basic/LangOptions.h @@ -220,7 +220,6 @@ class LangOptions : public LangOptionsBase { /// Attempt to be ABI-compatible with code generated by Clang 14.0.x. /// This causes clang to: /// - mangle dependent nested names incorrectly. - /// - pack non-POD members of packed structs. /// - make trivial only those defaulted copy constructors with a /// parameter-type-list equivalent to the parameter-type-list of an /// implicit declaration. @@ -229,6 +228,7 @@ class LangOptions : public LangOptionsBase { /// Attempt to be ABI-compatible with code generated by Clang 15.0.x. /// This causes clang to: /// - Reverse the implementation for DR692, DR1395 and DR1432. + /// - pack non-POD members of packed structs. Ver15, /// Conform to the underlying platform's C and C++ ABIs as closely diff --git a/clang/lib/AST/RecordLayoutBuilder.cpp b/clang/lib/AST/RecordLayoutBuilder.cpp index 6f3ede2ce42a7..dea7450613cc3 100644 --- a/clang/lib/AST/RecordLayoutBuilder.cpp +++ b/clang/lib/AST/RecordLayoutBuilder.cpp @@ -1892,7 +1892,7 @@ void ItaniumRecordLayoutBuilder::LayoutField(const FieldDecl *D, llvm::Triple Target = Context.getTargetInfo().getTriple(); bool FieldPacked = (Packed && (!FieldClass || FieldClass->isPOD() || Context.getLangOpts().getClangABICompat() <= - LangOptions::ClangABI::Ver14 || + LangOptions::ClangABI::Ver15 || Target.isPS() || Target.isOSDarwin())) || D->hasAttr<PackedAttr>(); diff --git a/clang/test/SemaCXX/class-layout.cpp b/clang/test/SemaCXX/class-layout.cpp index f81e526d0e2ad..df63141fc36dd 100644 --- a/clang/test/SemaCXX/class-layout.cpp +++ b/clang/test/SemaCXX/class-layout.cpp @@ -1,10 +1,10 @@ // RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify -std=c++98 -Wno-inaccessible-base // RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify -std=c++11 -Wno-inaccessible-base -// RUN: %clang_cc1 -triple x86_64-apple-darwin %s -fsyntax-only -verify -std=c++11 -Wno-inaccessible-base -DCLANG_ABI_COMPAT=14 +// RUN: %clang_cc1 -triple x86_64-apple-darwin %s -fsyntax-only -verify -std=c++11 -Wno-inaccessible-base -DCLANG_ABI_COMPAT=15 // RUN: %clang_cc1 -triple x86_64-scei-ps4 %s -fsyntax-only -verify -std=c++11 -Wno-inaccessible-base -DCLANG_ABI_COMPAT=6 // RUN: %clang_cc1 -triple x86_64-sie-ps5 %s -fsyntax-only -verify -std=c++11 -Wno-inaccessible-base -DCLANG_ABI_COMPAT=6 // RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify -std=c++11 -Wno-inaccessible-base -fclang-abi-compat=6 -DCLANG_ABI_COMPAT=6 -// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify -std=c++11 -Wno-inaccessible-base -fclang-abi-compat=14 -DCLANG_ABI_COMPAT=14 +// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify -std=c++11 -Wno-inaccessible-base -fclang-abi-compat=15 -DCLANG_ABI_COMPAT=15 // expected-no-diagnostics #define SA(n, p) int a##n[(p) ? 1 : -1] @@ -621,7 +621,7 @@ struct t2 { char c2; t1 v1; } __attribute__((packed)); -#if defined(CLANG_ABI_COMPAT) && CLANG_ABI_COMPAT <= 14 +#if defined(CLANG_ABI_COMPAT) && CLANG_ABI_COMPAT <= 15 _Static_assert(_Alignof(t1) == 4, ""); _Static_assert(_Alignof(t2) == 1, ""); #else _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits