[llvm-commits] [llvm-gcc-4.2] r75656 - /llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp

Chris Lattner sabre at nondot.org
Tue Jul 14 11:42:46 PDT 2009


Author: lattner
Date: Tue Jul 14 13:42:45 2009
New Revision: 75656

URL: http://llvm.org/viewvc/llvm-project?rev=75656&view=rev
Log:
fix PR4556 & test/FrontendC/2009-07-14-VoidPtr.c


Modified:
    llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp

Modified: llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp?rev=75656&r1=75655&r2=75656&view=diff

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp (original)
+++ llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp Tue Jul 14 13:42:45 2009
@@ -7780,8 +7780,10 @@
   // For example if the global's initializer has a different type to the global
   // itself (allowed in GCC but not in LLVM) then the global is changed to have
   // the type of the initializer.  Correct for this now.
-  return TheFolder->CreateBitCast(Val,
-                                  ConvertType(TREE_TYPE(exp))->getPointerTo());
+  const Type *Ty = ConvertType(TREE_TYPE(exp));
+  if (Ty == Type::VoidTy) Ty = Type::Int8Ty;  // void* -> i8*.
+  
+  return TheFolder->CreateBitCast(Val, Ty->getPointerTo());
 }
 
 /// EmitLV_LABEL_DECL - Someone took the address of a label.





More information about the llvm-commits mailing list