From 896c7dd62801c0aacf14b05183c3c471c1fe9f7a Mon Sep 17 00:00:00 2001 From: David Blaikie Date: Sat, 16 Feb 2013 00:56:22 +0000 Subject: [PATCH] Don't warn on conversion from NULL to nullptr_t git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@175331 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Sema/SemaChecking.cpp | 2 +- test/SemaCXX/conversion.cpp | 10 ++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/lib/Sema/SemaChecking.cpp b/lib/Sema/SemaChecking.cpp index 17ce614f7f..d76592438b 100644 --- a/lib/Sema/SemaChecking.cpp +++ b/lib/Sema/SemaChecking.cpp @@ -4939,7 +4939,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->isMemberPointerType() - && Target->isScalarType()) { + && Target->isScalarType() && !Target->isNullPtrType()) { SourceLocation Loc = E->getSourceRange().getBegin(); if (Loc.isMacroID()) Loc = S.SourceMgr.getImmediateExpansionRange(Loc).first; diff --git a/test/SemaCXX/conversion.cpp b/test/SemaCXX/conversion.cpp index ac235cc7fe..852bbba7ef 100644 --- a/test/SemaCXX/conversion.cpp +++ b/test/SemaCXX/conversion.cpp @@ -1,5 +1,5 @@ -// RUN: %clang_cc1 -triple x86_64-apple-darwin -fsyntax-only -Wconversion -verify %s -// RUN: %clang_cc1 -triple x86_64-apple-darwin -fsyntax-only -Wconversion %s 2>&1 | FileCheck %s +// RUN: %clang_cc1 -triple x86_64-apple-darwin -fsyntax-only -Wconversion -std=c++11 -verify %s +// RUN: %clang_cc1 -triple x86_64-apple-darwin -fsyntax-only -Wconversion -std=c++11 %s 2>&1 | FileCheck %s #include @@ -131,3 +131,9 @@ namespace test5 { template void func<3>(); } + +namespace test6 { + decltype(nullptr) func() { + return NULL; + } +} -- 2.40.0