From: Douglas Gregor Date: Sun, 22 Aug 2010 18:26:35 +0000 (+0000) Subject: Eliminate a stale assertion. Fixes Clang self-host. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=db68e28c05a67735211e688009890cf834c22e75;p=clang Eliminate a stale assertion. Fixes Clang self-host. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@111782 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/AST/Type.h b/include/clang/AST/Type.h index f5a4a1ff92..754f1f74ff 100644 --- a/include/clang/AST/Type.h +++ b/include/clang/AST/Type.h @@ -897,6 +897,7 @@ public: bool isFunctionPointerType() const; bool isMemberPointerType() const; bool isMemberFunctionPointerType() const; + bool isMemberDataPointerType() const; bool isArrayType() const; bool isConstantArrayType() const; bool isIncompleteArrayType() const; @@ -3486,6 +3487,12 @@ inline bool Type::isMemberFunctionPointerType() const { else return false; } +inline bool Type::isMemberDataPointerType() const { + if (const MemberPointerType* T = getAs()) + return !T->getPointeeType()->isFunctionType(); + else + return false; +} inline bool Type::isArrayType() const { return isa(CanonicalType); } diff --git a/lib/CodeGen/CGExprScalar.cpp b/lib/CodeGen/CGExprScalar.cpp index 38a49ee138..4d4ddd948c 100644 --- a/lib/CodeGen/CGExprScalar.cpp +++ b/lib/CodeGen/CGExprScalar.cpp @@ -569,12 +569,9 @@ EmitComplexToScalarConversion(CodeGenFunction::ComplexPairTy Src, Value *ScalarExprEmitter::EmitNullValue(QualType Ty) { const llvm::Type *LTy = ConvertType(Ty); - if (!Ty->isMemberPointerType()) + if (!Ty->isMemberDataPointerType()) return llvm::Constant::getNullValue(LTy); - assert(!Ty->isMemberFunctionPointerType() && - "member function pointers are not scalar!"); - // Itanium C++ ABI 2.3: // A NULL pointer is represented as -1. return llvm::ConstantInt::get(LTy, -1ULL, /*isSigned=*/true); diff --git a/test/CodeGenCXX/member-function-pointers.cpp b/test/CodeGenCXX/member-function-pointers.cpp index 0951174ca3..3e95f39a42 100644 --- a/test/CodeGenCXX/member-function-pointers.cpp +++ b/test/CodeGenCXX/member-function-pointers.cpp @@ -198,3 +198,14 @@ namespace test7 { void (C::*ptr4)() = &B::vfoo; void (C::*ptr5)() = &C::vfoo; } + +namespace test8 { + struct X { }; + typedef int (X::*pmf)(int); + + // CHECK: {{define.*_ZN5test81fEv}} + pmf f() { + // CHECK: {{ret.*zeroinitializer}} + return pmf(); + } +}