"Implicit cast types must be compatible");
Visit(E->getSubExpr());
break;
+
+ case CastExpr::CK_NullToMemberPointer: {
+ QualType T = E->getType();
+ const llvm::Type *PtrDiffTy =
+ CGF.ConvertType(CGF.getContext().getPointerDiffType());
+
+ llvm::Value *NullValue = llvm::Constant::getNullValue(PtrDiffTy);
+ llvm::Value *Ptr = Builder.CreateStructGEP(DestPtr, 0, "ptr");
+ Builder.CreateStore(NullValue, Ptr, VolatileDest);
+
+ llvm::Value *Adj = Builder.CreateStructGEP(DestPtr, 1, "adj");
+ Builder.CreateStore(NullValue, Adj, VolatileDest);
+
+ break;
+ }
}
}
return C;
}
+static inline bool isDataMemberPointerType(QualType T) {
+ if (const MemberPointerType *MPT = T->getAs<MemberPointerType>())
+ return !MPT->getPointeeType()->isFunctionType();
+
+ return false;
+}
+
llvm::Constant *CodeGenModule::EmitNullConstant(QualType T) {
// No need to check for member pointers when not compiling C++.
if (!getContext().getLangOptions().CPlusPlus)
QualType ElementTy = CAT->getElementType();
// FIXME: Handle arrays of structs that contain member pointers.
- if (Context.getBaseElementType(ElementTy)->isMemberPointerType()) {
+ if (isDataMemberPointerType(Context.getBaseElementType(ElementTy))) {
llvm::Constant *Element = EmitNullConstant(ElementTy);
uint64_t NumElements = CAT->getSize().getZExtValue();
std::vector<llvm::Constant *> Array(NumElements);
}
// FIXME: Handle structs that contain member pointers.
- if (T->isMemberPointerType())
+ if (isDataMemberPointerType(T))
return llvm::Constant::getAllOnesValue(getTypes().ConvertTypeForMem(T));
return llvm::Constant::getNullValue(getTypes().ConvertTypeForMem(T));
}
bool CodeGenFunction::hasAggregateLLVMType(QualType T) {
- return T->isRecordType() || T->isArrayType() || T->isAnyComplexType();
+ return T->isRecordType() || T->isArrayType() || T->isAnyComplexType() ||
+ T->isMemberFunctionPointerType();
}
void CodeGenFunction::EmitReturnBlock() {