[cfe-commits] r86287 - in /cfe/trunk: lib/CodeGen/CGRecordLayoutBuilder.cpp test/CodeGenCXX/empty-union.cpp
Fariborz Jahanian
fjahanian at apple.com
Fri Nov 6 12:47:40 PST 2009
Author: fjahanian
Date: Fri Nov 6 14:47:40 2009
New Revision: 86287
URL: http://llvm.org/viewvc/llvm-project?rev=86287&view=rev
Log:
Prevent a code gen. crash on empty unions - pr5408.
Added:
cfe/trunk/test/CodeGenCXX/empty-union.cpp
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=86287&r1=86286&r2=86287&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGRecordLayoutBuilder.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGRecordLayoutBuilder.cpp Fri Nov 6 14:47:40 2009
@@ -208,7 +208,11 @@
Align = 1;
}
}
-
+ if (!Align) {
+ assert((D->field_begin() == D->field_end()) && "LayoutUnion - Align 0");
+ Align = 1;
+ }
+
// Append tail padding.
if (Layout.getSize() / 8 > Size)
AppendPadding(Layout.getSize() / 8, Align);
Added: cfe/trunk/test/CodeGenCXX/empty-union.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/empty-union.cpp?rev=86287&view=auto
==============================================================================
--- cfe/trunk/test/CodeGenCXX/empty-union.cpp (added)
+++ cfe/trunk/test/CodeGenCXX/empty-union.cpp Fri Nov 6 14:47:40 2009
@@ -0,0 +1,10 @@
+// RUN: clang-cc -emit-llvm -o - %s
+
+union sigval { };
+
+union sigval sigev_value;
+
+int main()
+{
+ return sizeof(sigev_value);
+}
More information about the cfe-commits
mailing list