Move the bool-conversions behind the DiagRuntimeBehavior logic. It's
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.
llvm-svn: 126739
diff --git a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp
index f5316b5..14d545d 100644
--- a/clang/lib/Sema/SemaOverload.cpp
+++ b/clang/lib/Sema/SemaOverload.cpp
@@ -1939,8 +1939,8 @@
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>()) {
diff --git a/clang/test/SemaCXX/warn_false_to_pointer.cpp b/clang/test/SemaCXX/warn_false_to_pointer.cpp
index fb6f955..26b54f6 100644
--- a/clang/test/SemaCXX/warn_false_to_pointer.cpp
+++ b/clang/test/SemaCXX/warn_false_to_pointer.cpp
@@ -8,3 +8,10 @@
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;