diff options
author | Tanya Lattner <tonic@nondot.org> | 2009-09-04 20:02:56 +0000 |
---|---|---|
committer | Tanya Lattner <tonic@nondot.org> | 2009-09-04 20:02:56 +0000 |
commit | f8ef2e8d49b698b08269e01a475846a8d8b1cc51 (patch) | |
tree | 6c85e7752cc62a1e8636a83437481d03cac0960e | |
parent | 9304ff3568d9d1a95316aaa18e1ae3283044f313 (diff) |
Merge 80808 from mainline.
Packed unions should be packed. Fixes an assert Daniel reported.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/branches/release_26@81036 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/CodeGen/CGRecordLayoutBuilder.cpp | 3 | ||||
-rw-r--r-- | test/CodeGen/packed-union.c | 16 |
2 files changed, 17 insertions, 2 deletions
diff --git a/lib/CodeGen/CGRecordLayoutBuilder.cpp b/lib/CodeGen/CGRecordLayoutBuilder.cpp index 79d66209e8..3c7493f768 100644 --- a/lib/CodeGen/CGRecordLayoutBuilder.cpp +++ b/lib/CodeGen/CGRecordLayoutBuilder.cpp @@ -28,14 +28,13 @@ using namespace CodeGen; void CGRecordLayoutBuilder::Layout(const RecordDecl *D) { Alignment = Types.getContext().getASTRecordLayout(D).getAlignment() / 8; + Packed = D->hasAttr<PackedAttr>(); if (D->isUnion()) { LayoutUnion(D); return; } - Packed = D->hasAttr<PackedAttr>(); - if (LayoutFields(D)) return; diff --git a/test/CodeGen/packed-union.c b/test/CodeGen/packed-union.c new file mode 100644 index 0000000000..d11d3a4902 --- /dev/null +++ b/test/CodeGen/packed-union.c @@ -0,0 +1,16 @@ +// RUN: clang-cc -triple x86_64-apple-darwin10 -emit-llvm %s -o %t && + +// RUN: grep "struct._attrs = type <{ i32, i8 }>" %t && +typedef struct _attrs { + unsigned file_attributes; + unsigned char filename_length; +} __attribute__((__packed__)) attrs; + +// RUN: grep "union._attr_union = type <{ i32, i8 }>" %t +typedef union _attr_union { + attrs file_attrs; + unsigned owner_id; +} __attribute__((__packed__)) attr_union; + +attr_union u; + |