[cfe-commits] r80808 - in /cfe/trunk: lib/CodeGen/CGRecordLayoutBuilder.cpp test/CodeGen/packed-union.c
Anders Carlsson
andersca at mac.com
Wed Sep 2 10:51:34 PDT 2009
Author: andersca
Date: Wed Sep 2 12:51:33 2009
New Revision: 80808
URL: http://llvm.org/viewvc/llvm-project?rev=80808&view=rev
Log:
Packed unions should be packed. Fixes an assert Daniel reported.
Added:
cfe/trunk/test/CodeGen/packed-union.c
Modified:
cfe/trunk/lib/CodeGen/CGRecordLayoutBuilder.cpp
Modified: cfe/trunk/lib/CodeGen/CGRecordLayoutBuilder.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGRecordLayoutBuilder.cpp?rev=80808&r1=80807&r2=80808&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGRecordLayoutBuilder.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGRecordLayoutBuilder.cpp Wed Sep 2 12:51:33 2009
@@ -28,14 +28,13 @@
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;
Added: cfe/trunk/test/CodeGen/packed-union.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/packed-union.c?rev=80808&view=auto
==============================================================================
--- cfe/trunk/test/CodeGen/packed-union.c (added)
+++ cfe/trunk/test/CodeGen/packed-union.c Wed Sep 2 12:51:33 2009
@@ -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;
+
More information about the cfe-commits
mailing list