- /* Forbid using -- on `bool'. */ + /* Forbid using -- or ++ in C++17 on `bool'. */ if (TREE_CODE (declared_type) == BOOLEAN_TYPE) { if (code == POSTDECREMENT_EXPR || code == PREDECREMENT_EXPR) @@ -6040,6 +6040,20 @@ cp_build_unary_op (enum tree_code code, tree xarg, int noconvert, "to %<operator--%>"); return error_mark_node; } + else + { + if (cxx_dialect >= cxx1z) + { + if (complain & tf_error) + error ("use of Boolean expression as operand " + "to %<operator++%> is forbidden in C++1z");
The capitalization of Boolean here caught my eye because it's inconsistent with the recent spelling adopted in the documentation. (It's also missing an article "a Boolean expression," although dropping those is common in diagnostics. Still, it would be nice to have a guideline/convention and use it consistently.) Back to Boolean, I was actually going to comment on the Boolean -> boolean change and suggest going in the opposite direction but in the end decided not to (as Sandra's links showed, there's support for both). But having seen Boolean capitalized here I have changed my mind again. I'd like to (belatedly) speak up in support of Boolean (though I feel less strongly about it than I do about consistency). FWIW, I've always found the capitalized spelling more appropriate than the lowercase form. There are many examples of it, including the Wikipedia entries on Boolean algebra, Boolean expression, and Boolean data type, compiler manuals including those of HP C and aCC (though HP is inconsistent and uses both), the IBM XLC/C++ Language Reference, the Microsoft Visual Basic documentation of the type, the Wolfram MathWorld article on Boolean Algebra, and so on. Having said all that, since this is C++ the message could and arguably should refer to a bool expression (or type) instead and avoid having to deal with this altogether. In fact, it would be simpler to rephrase the message as: "use of an operand of type %qT in ... is deprecated", boolean_type_node As a separate issue, the message hardcodes operator++ but the comment farther above says: Forbid using -- or ++ in C++17 on `bool' Should it be parameterized on the kind expression and both expressions tested? Martin