[cfe-commits] r114955 - in /cfe/trunk: lib/Sema/SemaOverload.cpp test/SemaCXX/warn_false_to_pointer.cpp

Argyrios Kyrtzidis akyrtzi at gmail.com
Tue Sep 28 07:54:11 PDT 2010


Author: akirtzidis
Date: Tue Sep 28 09:54:11 2010
New Revision: 114955

URL: http://llvm.org/viewvc/llvm-project?rev=114955&view=rev
Log:
Don't warn with -Wbool-conversions if the user wrote an explicit cast like "(void *)false".
Fixes rdar://8459342.

Modified:
    cfe/trunk/lib/Sema/SemaOverload.cpp
    cfe/trunk/test/SemaCXX/warn_false_to_pointer.cpp

Modified: cfe/trunk/lib/Sema/SemaOverload.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOverload.cpp?rev=114955&r1=114954&r2=114955&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaOverload.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOverload.cpp Tue Sep 28 09:54:11 2010
@@ -1728,10 +1728,11 @@
                                   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;
 

Modified: cfe/trunk/test/SemaCXX/warn_false_to_pointer.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/warn_false_to_pointer.cpp?rev=114955&r1=114954&r2=114955&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/warn_false_to_pointer.cpp (original)
+++ cfe/trunk/test/SemaCXX/warn_false_to_pointer.cpp Tue Sep 28 09:54:11 2010
@@ -5,5 +5,6 @@
 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);
 }
 





More information about the cfe-commits mailing list