]> granicus.if.org Git - clang/commitdiff
Change the way clang generates union types a bit so it plays well
authorEli Friedman <eli.friedman@gmail.com>
Fri, 27 Feb 2009 04:53:40 +0000 (04:53 +0000)
committerEli Friedman <eli.friedman@gmail.com>
Fri, 27 Feb 2009 04:53:40 +0000 (04:53 +0000)
with the LLVM C backend.

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

lib/CodeGen/CodeGenTypes.cpp

index 091218305389297f07398d88ae1b59f09d6d4ca3..77131332e6d839ee62869b2cafd9aa14d435852e 100644 (file)
@@ -555,6 +555,11 @@ void RecordOrganizer::layoutUnionFields(const ASTRecordLayout &RL) {
   // of the result doesn't matter because anyone allocating
   // structures should be aligning them appropriately anyway.
   // FIXME: We can be a bit more intuitive in a lot of cases.
-  STy = llvm::ArrayType::get(llvm::Type::Int8Ty, RL.getSize() / 8);
+  // FIXME: Make this a struct type to work around PR2399; the
+  // C backend doesn't like structs using array types.
+  std::vector<const llvm::Type*> LLVMFields;
+  LLVMFields.push_back(llvm::ArrayType::get(llvm::Type::Int8Ty,
+                                            RL.getSize() / 8));
+  STy = llvm::StructType::get(LLVMFields, true);
   assert(CGT.getTargetData().getTypePaddedSizeInBits(STy) == RL.getSize());
 }