From 6d0e5bd8f35e8152d5cf071da875eb873e8aec7b Mon Sep 17 00:00:00 2001 From: Anders Carlsson Date: Sun, 7 Feb 2010 17:37:13 +0000 Subject: Use the right type when taking the address of a non-virtual member function pointer. Fixes PR6258. llvm-svn: 95524 --- clang/lib/CodeGen/CGExprAgg.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'clang/lib/CodeGen/CGExprAgg.cpp') diff --git a/clang/lib/CodeGen/CGExprAgg.cpp b/clang/lib/CodeGen/CGExprAgg.cpp index bdeecb85be15..b6340dcbb923 100644 --- a/clang/lib/CodeGen/CGExprAgg.cpp +++ b/clang/lib/CodeGen/CGExprAgg.cpp @@ -333,8 +333,12 @@ void AggExprEmitter::VisitUnaryAddrOf(const UnaryOperator *E) { // (in bytes) of the function, represented as a ptrdiff_t. FuncPtr = llvm::ConstantInt::get(PtrDiffTy, (Index * 8) + 1); } else { - FuncPtr = llvm::ConstantExpr::getPtrToInt(CGF.CGM.GetAddrOfFunction(MD), - PtrDiffTy); + const FunctionProtoType *FPT = MD->getType()->getAs(); + const llvm::Type *Ty = + CGF.CGM.getTypes().GetFunctionType(CGF.CGM.getTypes().getFunctionInfo(MD), + FPT->isVariadic()); + llvm::Constant *Fn = CGF.CGM.GetAddrOfFunction(MD, Ty); + FuncPtr = llvm::ConstantExpr::getPtrToInt(Fn, PtrDiffTy); } Builder.CreateStore(FuncPtr, DstPtr, VolatileDest); -- cgit v1.2.3