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())) ||
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())) ||
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits