r257231 - Exclude function calls for functions which have return type nullptr_t from

Richard Trieu via cfe-commits cfe-commits at lists.llvm.org
Fri Jan 8 15:35:06 PST 2016


Author: rtrieu
Date: Fri Jan  8 17:35:06 2016
New Revision: 257231

URL: http://llvm.org/viewvc/llvm-project?rev=257231&view=rev
Log:
Exclude function calls for functions which have return type nullptr_t from
-Wnull-conversion warning.

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

Modified:
    cfe/trunk/lib/Sema/SemaChecking.cpp
    cfe/trunk/test/SemaCXX/conversion.cpp

Modified: cfe/trunk/lib/Sema/SemaChecking.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=257231&r1=257230&r2=257231&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaChecking.cpp (original)
+++ cfe/trunk/lib/Sema/SemaChecking.cpp Fri Jan  8 17:35:06 2016
@@ -7047,6 +7047,10 @@ static void DiagnoseNullConversion(Sema
                         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);

Modified: cfe/trunk/test/SemaCXX/conversion.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/conversion.cpp?rev=257231&r1=257230&r2=257231&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/conversion.cpp (original)
+++ cfe/trunk/test/SemaCXX/conversion.cpp Fri Jan  8 17:35:06 2016
@@ -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();
+  }
+}




More information about the cfe-commits mailing list