This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: C++ PATCH to forbid use of bool with the ++ operator


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]