From: Devang Patel Date: Wed, 7 May 2008 22:28:29 +0000 (+0000) Subject: Begin handling union bitfields. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=5cada6bd7f0a9f1c0f82613924610177d676ced5;p=clang Begin handling union bitfields. Note, this is just beginning. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@50835 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/CodeGen/CodeGenTypes.cpp b/lib/CodeGen/CodeGenTypes.cpp index 751cd3a077..1544050155 100644 --- a/lib/CodeGen/CodeGenTypes.cpp +++ b/lib/CodeGen/CodeGenTypes.cpp @@ -593,12 +593,14 @@ void RecordOrganizer::layoutUnionFields() { unsigned PrimaryEltNo = 0; std::pair PrimaryElt = CGT.getContext().getTypeInfo(FieldDecls[0]->getType()); - CGT.addFieldInfo(FieldDecls[0], 0); + if (FieldDecls[0]->isBitField()) + placeBitField(FieldDecls[0]); + else + CGT.addFieldInfo(FieldDecls[0], 0); unsigned Size = FieldDecls.size(); for(unsigned i = 1; i != Size; ++i) { const FieldDecl *FD = FieldDecls[i]; - assert (!FD->isBitField() && "Bit fields are not yet supported"); std::pair EltInfo = CGT.getContext().getTypeInfo(FD->getType()); @@ -611,7 +613,10 @@ void RecordOrganizer::layoutUnionFields() { } // In union, each field gets first slot. - CGT.addFieldInfo(FD, 0); + if (FD->isBitField()) + placeBitField(FD); + else + CGT.addFieldInfo(FD, 0); } std::vector Fields; diff --git a/test/CodeGen/union.c b/test/CodeGen/union.c index 4d32abdf54..b47e697adc 100644 --- a/test/CodeGen/union.c +++ b/test/CodeGen/union.c @@ -26,3 +26,8 @@ typedef union { int i; int *j; } value; int f3(value v) { return *v.j; } + +enum E9 { one, two }; +union S65 { enum E9 a:62; } ; union S65 s65; +void fS65() { enum E9 e = s65.a; } +