[Bug c++/79184] [7 Regression] -Wint-in-bool-context triggered erroneously in template parameter
mpolacek at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Fri Feb 10 11:38:00 GMT 2017
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79184
--- Comment #3 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
I suppose we'll have to use something like
--- a/gcc/cp/cvt.c
+++ b/gcc/cp/cvt.c
@@ -798,7 +798,15 @@ ocp_convert (tree type, tree expr, int convtype, int
flags,
to the underlying type first. */
if (SCOPED_ENUM_P (intype) && (convtype & CONV_STATIC))
e = build_nop (ENUM_UNDERLYING_TYPE (intype), e);
- return cp_truthvalue_conversion (e);
+ if (complain & tf_warning)
+ return cp_truthvalue_conversion (e);
+ else
+ {
+ /* Prevent bogus -Wint-in-bool-context warnings coming
+ from c_common_truthvalue_conversion down the line. */
+ warning_sentinel w (warn_int_in_bool_context);
+ return cp_truthvalue_conversion (e);
+ }
}
converted = convert_to_integer_maybe_fold (type, e, dofold);
(that makes g++ not warn at all on the test from Comment 2)
More information about the Gcc-bugs
mailing list