From 77c006d1e83a7053e170777f572b10268fe99c69 Mon Sep 17 00:00:00 2001 From: Richard Trieu Date: Fri, 8 Jan 2016 23:35:06 +0000 Subject: [PATCH] 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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@257231 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Sema/SemaChecking.cpp | 4 ++++ test/SemaCXX/conversion.cpp | 11 +++++++++++ 2 files changed, 15 insertions(+) diff --git a/lib/Sema/SemaChecking.cpp b/lib/Sema/SemaChecking.cpp index cbdcb5e483..0c4b59e3ce 100644 --- a/lib/Sema/SemaChecking.cpp +++ b/lib/Sema/SemaChecking.cpp @@ -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(E)) + return; + // Check for NULL (GNUNull) or nullptr (CXX11_nullptr). const Expr::NullPointerConstantKind NullKind = E->isNullPointerConstant(S.Context, Expr::NPC_ValueDependentIsNotNull); diff --git a/test/SemaCXX/conversion.cpp b/test/SemaCXX/conversion.cpp index 89751a493e..2c83147ff4 100644 --- a/test/SemaCXX/conversion.cpp +++ b/test/SemaCXX/conversion.cpp @@ -197,3 +197,14 @@ namespace test8 { template_and_macro2(); } } + +// 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(); + } +} -- 2.40.0