[PATCH] D119051: Fix pod-packed functionality to use the C++11 definition of pod-ness
David Blaikie via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Feb 4 20:07:35 PST 2022
dblaikie created this revision.
dblaikie added reviewers: rsmith, Bhramar.vatsa, rjmccall, rnk.
dblaikie requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D119051
Files:
clang/lib/AST/RecordLayoutBuilder.cpp
clang/test/SemaCXX/class-layout.cpp
Index: clang/test/SemaCXX/class-layout.cpp
===================================================================
--- clang/test/SemaCXX/class-layout.cpp
+++ clang/test/SemaCXX/class-layout.cpp
@@ -641,3 +641,14 @@
_Static_assert(_Alignof(t1) == 1, "");
_Static_assert(_Alignof(t2) == 1, "");
} // namespace non_pod_packed
+
+namespace cxx11_pod {
+struct t1 {
+ t1() = default;
+ int a;
+};
+struct t2 {
+ t1 v1;
+} __attribute__((packed));
+_Static_assert(_Alignof(t2) == 1, "");
+}
Index: clang/lib/AST/RecordLayoutBuilder.cpp
===================================================================
--- clang/lib/AST/RecordLayoutBuilder.cpp
+++ clang/lib/AST/RecordLayoutBuilder.cpp
@@ -1888,11 +1888,12 @@
LastBitfieldStorageUnitSize = 0;
llvm::Triple Target = Context.getTargetInfo().getTriple();
- bool FieldPacked = (Packed && (!FieldClass || FieldClass->isPOD() ||
- Context.getLangOpts().getClangABICompat() <=
- LangOptions::ClangABI::Ver13 ||
- Target.isPS4() || Target.isOSDarwin())) ||
- D->hasAttr<PackedAttr>();
+ bool FieldPacked =
+ (Packed && (!FieldClass || D->getType().isCXX11PODType(Context) ||
+ Context.getLangOpts().getClangABICompat() <=
+ LangOptions::ClangABI::Ver13 ||
+ Target.isPS4() || Target.isOSDarwin())) ||
+ D->hasAttr<PackedAttr>();
AlignRequirementKind AlignRequirement = AlignRequirementKind::None;
CharUnits FieldSize;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D119051.406148.patch
Type: text/x-patch
Size: 1562 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220205/af14668a/attachment-0001.bin>
More information about the cfe-commits
mailing list