[PATCH] D135916: Itanium ABI: Pack non-pod members of packed types

David Blaikie via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Oct 14 12:33:21 PDT 2022


This revision was automatically updated to reflect the committed changes.
Closed by commit rG037f85668126: Itanium ABI: Pack non-pod members of packed types (authored by dblaikie).

Changed prior to commit:
  https://reviews.llvm.org/D135916?vs=467599&id=467890#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D135916/new/

https://reviews.llvm.org/D135916

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
@@ -642,3 +642,17 @@
 _Static_assert(_Alignof(t1) == 1, "");
 _Static_assert(_Alignof(t2) == 1, "");
 } // namespace non_pod_packed
+
+namespace non_pod_packed_packed {
+struct B {
+  int b;
+};
+struct  FromB : B {
+} __attribute__((packed));
+struct C {
+  char a[3];
+  FromB b;
+} __attribute__((packed));
+_Static_assert(__builtin_offsetof(C, b) == 3, "");
+}
+
Index: clang/lib/AST/RecordLayoutBuilder.cpp
===================================================================
--- clang/lib/AST/RecordLayoutBuilder.cpp
+++ clang/lib/AST/RecordLayoutBuilder.cpp
@@ -1891,6 +1891,7 @@
 
   llvm::Triple Target = Context.getTargetInfo().getTriple();
   bool FieldPacked = (Packed && (!FieldClass || FieldClass->isPOD() ||
+                                 FieldClass->hasAttr<PackedAttr>() ||
                                  Context.getLangOpts().getClangABICompat() <=
                                      LangOptions::ClangABI::Ver15 ||
                                  Target.isPS() || Target.isOSDarwin())) ||


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D135916.467890.patch
Type: text/x-patch
Size: 1209 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20221014/874355f1/attachment-0001.bin>


More information about the cfe-commits mailing list