diff options
Diffstat (limited to 'clang/lib')
| -rw-r--r-- | clang/lib/CodeGen/CGExprConstant.cpp | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/clang/lib/CodeGen/CGExprConstant.cpp b/clang/lib/CodeGen/CGExprConstant.cpp index d64c5876ee2..8ad1a4d29cd 100644 --- a/clang/lib/CodeGen/CGExprConstant.cpp +++ b/clang/lib/CodeGen/CGExprConstant.cpp @@ -1314,8 +1314,14 @@ llvm::Constant *CodeGenModule::EmitConstantValue(const APValue &Value, // Convert to the appropriate type; this could be an lvalue for // an integer. - if (isa<llvm::PointerType>(DestTy)) + if (isa<llvm::PointerType>(DestTy)) { + // Convert the integer to a pointer-sized integer before converting it + // to a pointer. + C = llvm::ConstantExpr::getIntegerCast( + C, getDataLayout().getIntPtrType(DestTy), + /*isSigned=*/false); return llvm::ConstantExpr::getIntToPtr(C, DestTy); + } // If the types don't match this should only be a truncate. if (C->getType() != DestTy) |

