]> granicus.if.org Git - clang/commitdiff
Move the bool-conversions behind the DiagRuntimeBehavior logic. It's
authorChandler Carruth <chandlerc@gmail.com>
Tue, 1 Mar 2011 03:29:37 +0000 (03:29 +0000)
committerChandler Carruth <chandlerc@gmail.com>
Tue, 1 Mar 2011 03:29:37 +0000 (03:29 +0000)
possible for these to show up due to metaprogramming both in unevaluated
contexts and compile-time dead branches.

Those aren't the bugs we're looking for.

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

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

index f5316b564e2e6f931781a1144619a505ec1e3a7a..14d545d3e48be472224549a6999c6ef313a8f903 100644 (file)
@@ -1939,8 +1939,8 @@ bool Sema::CheckPointerConversion(Expr *From, QualType ToType,
   if (CXXBoolLiteralExpr* LitBool
                           = dyn_cast<CXXBoolLiteralExpr>(From->IgnoreParens()))
     if (!IsCStyleOrFunctionalCast && LitBool->getValue() == false)
-      Diag(LitBool->getExprLoc(), diag::warn_init_pointer_from_false)
-        << ToType;
+      DiagRuntimeBehavior(LitBool->getExprLoc(), From,
+                          PDiag(diag::warn_init_pointer_from_false) << ToType);
 
   if (const PointerType *FromPtrType = FromType->getAs<PointerType>())
     if (const PointerType *ToPtrType = ToType->getAs<PointerType>()) {
index fb6f9551a7ac594997ca0b1987c224bee28d1ffd..26b54f6e685b3588b5b0940fcfab64b5d5e7d6a2 100644 (file)
@@ -8,3 +8,10 @@ void foo(int* i, int *j=(false)) // expected-warning{{ initialization of pointer
   foo((int*)false);
 }
 
+char f(struct Undefined*);
+double f(...);
+
+// Ensure that when using false in metaprogramming machinery its conversion
+// isn't flagged.
+template <int N> struct S {};
+S<sizeof(f(false))> s;