]> granicus.if.org Git - clang/commitdiff
Don't warn with -Wbool-conversions if the user wrote an explicit cast like "(void...
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>
Tue, 28 Sep 2010 14:54:11 +0000 (14:54 +0000)
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>
Tue, 28 Sep 2010 14:54:11 +0000 (14:54 +0000)
Fixes rdar://8459342.

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

lib/Sema/SemaOverload.cpp
test/SemaCXX/warn_false_to_pointer.cpp

index a7e5e3ae71574e14454ef79b0c8bc1138a49d2b1..919aea8d024abab2b88822d30c3ef2ae1641ed25 100644 (file)
@@ -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;
 
index 3a873d886f0e8efe9dacf2639a63175f2dc08937..fb6f9551a7ac594997ca0b1987c224bee28d1ffd 100644 (file)
@@ -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);
 }