diff options
author | Chris Lattner <sabre@nondot.org> | 2007-12-10 19:50:32 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2007-12-10 19:50:32 +0000 |
commit | 4fd46bc65115e5c37b412f5420e99f9b587d4010 (patch) | |
tree | e69f0bbb2480e9a19ea8f33460574c34ec693357 /CodeGen/CodeGenModule.cpp | |
parent | 05f753b996a6ea712ab06787190fb3287610fc59 (diff) |
add support for implicit cast from array to pointer that is not the element
type.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@44809 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'CodeGen/CodeGenModule.cpp')
-rw-r--r-- | CodeGen/CodeGenModule.cpp | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/CodeGen/CodeGenModule.cpp b/CodeGen/CodeGenModule.cpp index 2ce7f4e837..a5f7df18d4 100644 --- a/CodeGen/CodeGenModule.cpp +++ b/CodeGen/CodeGenModule.cpp @@ -404,7 +404,14 @@ static llvm::Constant *GenerateConstantExpr(const Expr *Expression, llvm::Constant *Idx0 = llvm::ConstantInt::get(llvm::Type::Int32Ty, 0); llvm::Constant *Ops[] = {Idx0, Idx0}; - return llvm::ConstantExpr::getGetElementPtr(C, Ops, 2); + C = llvm::ConstantExpr::getGetElementPtr(C, Ops, 2); + + // The resultant pointer type can be implicitly casted to other pointer + // types as well, for example void*. + const llvm::Type *DestPTy = Types.ConvertType(type); + assert(isa<llvm::PointerType>(DestPTy) && + "Only expect implicit cast to pointer"); + return llvm::ConstantExpr::getBitCast(C, DestPTy); } // If this is an implicit cast of a string literal to an array type, this |