]> granicus.if.org Git - clang/commitdiff
PR13165: False positive when initializing member data pointers with NULL.
authorDavid Blaikie <dblaikie@gmail.com>
Thu, 21 Jun 2012 18:51:10 +0000 (18:51 +0000)
committerDavid Blaikie <dblaikie@gmail.com>
Thu, 21 Jun 2012 18:51:10 +0000 (18:51 +0000)
This now correctly covers, I believe, all the pointer types:
* 'any' pointers (both function and data normal pointers and ObjC object pointers)
* member pointers (both function and data)
* block pointers

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@158931 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaChecking.cpp
test/SemaCXX/conversion.cpp

index fe5e8aca3dd536138e3a3392a38b68c1dedae14e..ef7dc8819f8194d4e0e4e791a0762bb512934475 100644 (file)
@@ -4432,8 +4432,7 @@ void CheckImplicitConversion(Sema &S, Expr *E, QualType T,
 
   if ((E->isNullPointerConstant(S.Context, Expr::NPC_ValueDependentIsNotNull)
            == Expr::NPCK_GNUNull) && !Target->isAnyPointerType()
-      && !Target->isBlockPointerType() && !Target->isFunctionPointerType()
-      && !Target->isMemberFunctionPointerType()) {
+      && !Target->isBlockPointerType() && !Target->isMemberPointerType()) {
     SourceLocation Loc = E->getSourceRange().getBegin();
     if (Loc.isMacroID())
       Loc = S.SourceMgr.getImmediateExpansionRange(Loc).first;
index ad6e321dd33c7eb26fb609e14dec7754c35178db..ac235cc7feafd833e14762516c9d7727ee7157a0 100644 (file)
@@ -90,6 +90,14 @@ void test3() {
     ;
   do ;
   while(NULL_COND(true));
+  int *ip = NULL;
+  int (*fp)() = NULL;
+  struct foo {
+    int n;
+    void func();
+  };
+  int foo::*datamem = NULL;
+  int (foo::*funmem)() = NULL;
 }
 
 namespace test4 {