diff options
| -rw-r--r-- | clang/lib/CodeGen/CodeGenTypes.cpp | 11 | ||||
| -rw-r--r-- | clang/test/CodeGen/union.c | 5 | 
2 files changed, 13 insertions, 3 deletions
diff --git a/clang/lib/CodeGen/CodeGenTypes.cpp b/clang/lib/CodeGen/CodeGenTypes.cpp index 751cd3a0777..15440501559 100644 --- a/clang/lib/CodeGen/CodeGenTypes.cpp +++ b/clang/lib/CodeGen/CodeGenTypes.cpp @@ -593,12 +593,14 @@ void RecordOrganizer::layoutUnionFields() {    unsigned PrimaryEltNo = 0;    std::pair<uint64_t, unsigned> 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<uint64_t, unsigned> 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<const llvm::Type*> Fields; diff --git a/clang/test/CodeGen/union.c b/clang/test/CodeGen/union.c index 4d32abdf54d..b47e697adc5 100644 --- a/clang/test/CodeGen/union.c +++ b/clang/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; }  +  | 

