Skip to content
Snippets Groups Projects
Commit e8e631c9 authored by Fariborz Jahanian's avatar Fariborz Jahanian
Browse files

Prevent a code gen. crash on empty unions - pr5408.

llvm-svn: 86287
parent e3423e84
No related branches found
No related tags found
No related merge requests found
...@@ -208,7 +208,11 @@ void CGRecordLayoutBuilder::LayoutUnion(const RecordDecl *D) { ...@@ -208,7 +208,11 @@ void CGRecordLayoutBuilder::LayoutUnion(const RecordDecl *D) {
Align = 1; Align = 1;
} }
} }
if (!Align) {
assert((D->field_begin() == D->field_end()) && "LayoutUnion - Align 0");
Align = 1;
}
// Append tail padding. // Append tail padding.
if (Layout.getSize() / 8 > Size) if (Layout.getSize() / 8 > Size)
AppendPadding(Layout.getSize() / 8, Align); AppendPadding(Layout.getSize() / 8, Align);
......
// RUN: clang-cc -emit-llvm -o - %s
union sigval { };
union sigval sigev_value;
int main()
{
return sizeof(sigev_value);
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment