diff options
author | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2010-09-28 14:54:11 +0000 |
---|---|---|
committer | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2010-09-28 14:54:11 +0000 |
commit | b3358724d985dc08889f7905f20284718361e885 (patch) | |
tree | 8dbf4dda1e6b308e9b16366a2a07337ae0713cc7 | |
parent | 1a18600b85aaa691122983dd8dcf4225cfc9ef68 (diff) |
Don't warn with -Wbool-conversions if the user wrote an explicit cast like "(void *)false".
Fixes rdar://8459342.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@114955 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/Sema/SemaOverload.cpp | 3 | ||||
-rw-r--r-- | test/SemaCXX/warn_false_to_pointer.cpp | 1 |
2 files changed, 3 insertions, 1 deletions
diff --git a/lib/Sema/SemaOverload.cpp b/lib/Sema/SemaOverload.cpp index a7e5e3ae71..919aea8d02 100644 --- a/lib/Sema/SemaOverload.cpp +++ b/lib/Sema/SemaOverload.cpp @@ -1728,10 +1728,11 @@ bool Sema::CheckPointerConversion(Expr *From, QualType ToType, CXXCastPath& BasePath, bool IgnoreBaseAccess) { QualType FromType = From->getType(); + bool IsCStyleOrFunctionalCast = IgnoreBaseAccess; if (CXXBoolLiteralExpr* LitBool = dyn_cast<CXXBoolLiteralExpr>(From->IgnoreParens())) - if (LitBool->getValue() == false) + if (!IsCStyleOrFunctionalCast && LitBool->getValue() == false) Diag(LitBool->getExprLoc(), diag::warn_init_pointer_from_false) << ToType; diff --git a/test/SemaCXX/warn_false_to_pointer.cpp b/test/SemaCXX/warn_false_to_pointer.cpp index 3a873d886f..fb6f9551a7 100644 --- a/test/SemaCXX/warn_false_to_pointer.cpp +++ b/test/SemaCXX/warn_false_to_pointer.cpp @@ -5,5 +5,6 @@ int* j = false; // expected-warning{{ initialization of pointer of type 'int *' void foo(int* i, int *j=(false)) // expected-warning{{ initialization of pointer of type 'int *' from literal 'false'}} { foo(false); // expected-warning{{ initialization of pointer of type 'int *' from literal 'false'}} + foo((int*)false); } |