]> granicus.if.org Git - clang/commitdiff
Eliminate a stale assertion. Fixes Clang self-host.
authorDouglas Gregor <dgregor@apple.com>
Sun, 22 Aug 2010 18:26:35 +0000 (18:26 +0000)
committerDouglas Gregor <dgregor@apple.com>
Sun, 22 Aug 2010 18:26:35 +0000 (18:26 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@111782 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/AST/Type.h
lib/CodeGen/CGExprScalar.cpp
test/CodeGenCXX/member-function-pointers.cpp

index f5a4a1ff92440d7dd92a6e316aa50cb636ed3062..754f1f74ffc94537424a12ea35d5d5a769d9253f 100644 (file)
@@ -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<MemberPointerType>())
+    return !T->getPointeeType()->isFunctionType();
+  else
+    return false;
+}
 inline bool Type::isArrayType() const {
   return isa<ArrayType>(CanonicalType);
 }
index 38a49ee138dde4ccff8db6de65495bd373349a86..4d4ddd948c2a9429a96aab8af67429f3886e1394 100644 (file)
@@ -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);  
index 0951174ca3cb9f3dc6e8a6a4d8b8fa405d647a54..3e95f39a4239d8a0e21d292402c01de90eb547a7 100644 (file)
@@ -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();
+  }
+}