]> granicus.if.org Git - clang/commitdiff
Exclude function calls for functions which have return type nullptr_t from
authorRichard Trieu <rtrieu@google.com>
Fri, 8 Jan 2016 23:35:06 +0000 (23:35 +0000)
committerRichard Trieu <rtrieu@google.com>
Fri, 8 Jan 2016 23:35:06 +0000 (23:35 +0000)
-Wnull-conversion warning.

These functions are basically equivalent to other pointer returning fuctions
which are already excluded by -Wnull-conversion.

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

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

index cbdcb5e48391d3314dadad405dbbcfedbfd97d9b..0c4b59e3ce1f62568cc283c951d32f87dc94d4e5 100644 (file)
@@ -7047,6 +7047,10 @@ static void DiagnoseNullConversion(Sema &S, Expr *E, QualType T,
                         E->getExprLoc()))
     return;
 
+  // Don't warn on functions which have return type nullptr_t.
+  if (isa<CallExpr>(E))
+    return;
+
   // Check for NULL (GNUNull) or nullptr (CXX11_nullptr).
   const Expr::NullPointerConstantKind NullKind =
       E->isNullPointerConstant(S.Context, Expr::NPC_ValueDependentIsNotNull);
index 89751a493eef69831d4133c5ff279d1e60b19bf5..2c83147ff4c480b00425d50d50f98a2284f4d32c 100644 (file)
@@ -197,3 +197,14 @@ namespace test8 {
     template_and_macro2<double>();
   }
 }
+
+// Don't warn on a nullptr to bool conversion when the nullptr is the return
+// type of a function.
+namespace test9 {
+  typedef decltype(nullptr) nullptr_t;
+  nullptr_t EXIT();
+
+  bool test() {
+    return EXIT();
+  }
+}