From 7f78d85be4fc2f8ccda63cba546dad7c9ec8267b Mon Sep 17 00:00:00 2001 From: Anders Carlsson Date: Sat, 26 Sep 2009 01:29:10 +0000 Subject: [PATCH] Start at NextOffset when laying out bases as well. llvm-svn: 82831 --- clang/lib/AST/RecordLayoutBuilder.cpp | 2 +- clang/test/SemaCXX/empty-class-layout.cpp | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/clang/lib/AST/RecordLayoutBuilder.cpp b/clang/lib/AST/RecordLayoutBuilder.cpp index d84b0d130034..1b06bceef9bb 100644 --- a/clang/lib/AST/RecordLayoutBuilder.cpp +++ b/clang/lib/AST/RecordLayoutBuilder.cpp @@ -377,7 +377,7 @@ uint64_t ASTRecordLayoutBuilder::LayoutBase(const CXXRecordDecl *RD) { unsigned BaseAlign = BaseInfo.getNonVirtualAlign(); // Round up the current record size to the base's alignment boundary. - uint64_t Offset = llvm::RoundUpToAlignment(Size, BaseAlign); + uint64_t Offset = llvm::RoundUpToAlignment(NextOffset, BaseAlign); // Try to place the base. while (true) { diff --git a/clang/test/SemaCXX/empty-class-layout.cpp b/clang/test/SemaCXX/empty-class-layout.cpp index e4e62aa36915..8b54ea1c66f2 100644 --- a/clang/test/SemaCXX/empty-class-layout.cpp +++ b/clang/test/SemaCXX/empty-class-layout.cpp @@ -62,3 +62,7 @@ struct S7 : Empty { void *v; }; SA(11, sizeof(S7) == 8); + +struct S8 : Empty, A { +}; +SA(12, sizeof(S8) == 4);