This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: C++ PATCH to forbid use of bool with the ++ operator
- From: Marek Polacek <polacek at redhat dot com>
- To: Martin Sebor <msebor at gmail dot com>
- Cc: GCC Patches <gcc-patches at gcc dot gnu dot org>, Jason Merrill <jason at redhat dot com>
- Date: Wed, 14 Sep 2016 15:08:16 +0200
- Subject: Re: C++ PATCH to forbid use of bool with the ++ operator
- Authentication-results: sourceware.org; auth=none
- References: <20160913183633.GO19950@redhat.com> <57D859CC.8020001@gmail.com>
On Tue, Sep 13, 2016 at 01:55:56PM -0600, Martin Sebor wrote:
> > - /* 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).
Well, my point was to get rid of this inconsistency, I don't really
care whether it's Boolean or boolean. But since boolean was used
most of the time, I went with that.
Marek