]> granicus.if.org Git - clang/commitdiff
Begin handling union bitfields.
authorDevang Patel <dpatel@apple.com>
Wed, 7 May 2008 22:28:29 +0000 (22:28 +0000)
committerDevang Patel <dpatel@apple.com>
Wed, 7 May 2008 22:28:29 +0000 (22:28 +0000)
Note, this is just beginning.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@50835 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CodeGenTypes.cpp
test/CodeGen/union.c

index 751cd3a07778b1c91013ead1cc47fc4d42ed4543..154405015592d6980edf14632582832f06b40462 100644 (file)
@@ -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;
index 4d32abdf54dff3639cafa8725b58088e329a31e8..b47e697adc5179cb139f0d77562daf961346ebd2 100644 (file)
@@ -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; } 
+