This warning is of questionable value when it's emitted when
instantiating a template, as in the following testcase. It could be
silenced by writing hb(i) << 1 instead of 2 * hb(i) but that's
unnecessary obfuscation.
gcc/cp/ChangeLog:
* pt.c (tsubst_copy_and_build): Add warn_int_in_bool_context
sentinel.
gcc/testsuite/ChangeLog:
* g++.dg/warn/Wint-in-bool-context-2.C: New test.
warning_sentinel s(warn_useless_cast);
warning_sentinel s2(warn_ignored_qualifiers);
+ warning_sentinel s3(warn_int_in_bool_context);
switch (TREE_CODE (t))
{
case CAST_EXPR:
--- /dev/null
+// { dg-do compile { target c++11 } }
+// { dg-options "-Wint-in-bool-context" }
+
+unsigned hb(unsigned i) { return ~i; }
+
+template<typename T>
+void f(int i)
+{
+ auto l = [i]() { return T(2 * hb(i)); }; // { dg-bogus "in boolean context" }
+ (void) l;
+}
+
+int main()
+{
+ f<bool>(0);
+}