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

2016-09-21 Thread Marek Polacek
On Wed, Sep 21, 2016 at 03:45:55PM -0400, Jason Merrill wrote: > On Wed, Sep 14, 2016 at 1:38 PM, Jason Merrill wrote: > >> * c-c++-common/gomp/atomic-12.c: Use -Wno-deprecated. > >> * c-c++-common/gomp/atomic-13.c: Likewise. > >> *

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

2016-09-21 Thread Jason Merrill
On Wed, Sep 14, 2016 at 1:38 PM, Jason Merrill wrote: >> * c-c++-common/gomp/atomic-12.c: Use -Wno-deprecated. >> * c-c++-common/gomp/atomic-13.c: Likewise. >> * c-c++-common/gomp/atomic-14.c: Likewise. >> * g++.dg/cpp1y/lambda-init11.C: Remove

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

2016-09-15 Thread Jonathan Wakely
On 14/09/16 17:28 +0200, Marek Polacek wrote: diff --git gcc/libstdc++-v3/testsuite/23_containers/vector/debug/insert6_neg.cc gcc/libstdc++-v3/testsuite/23_containers/vector/debug/insert6_neg.cc index 9893293..c939c22 100644 ---

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

2016-09-14 Thread Jason Merrill
OK, thanks. On Wed, Sep 14, 2016 at 11:28 AM, Marek Polacek wrote: > On Tue, Sep 13, 2016 at 11:37:20PM -0400, Jason Merrill wrote: >> On Tue, Sep 13, 2016 at 3:55 PM, Martin Sebor wrote: >> > Having said all that, since this is C++ the message could and >>

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

2016-09-14 Thread Marek Polacek
On Tue, Sep 13, 2016 at 11:37:20PM -0400, Jason Merrill wrote: > On Tue, Sep 13, 2016 at 3:55 PM, Martin Sebor wrote: > > 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

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

2016-09-14 Thread Jason Merrill
On Wed, Sep 14, 2016 at 9:08 AM, Marek Polacek wrote: > 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) >>

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

2016-09-14 Thread Marek Polacek
On Wed, Sep 14, 2016 at 10:54:35AM -0400, Jason Merrill wrote: > Martin's point, which I agree with, is that for C++ we want to use > "bool" rather than either of those. Sure, I'm testing another version of this patch which has this fixed. Marek

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

2016-09-14 Thread Marek Polacek
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 ==

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

2016-09-13 Thread Jason Merrill
On Tue, Sep 13, 2016 at 3:55 PM, Martin Sebor wrote: > 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

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

2016-09-13 Thread Martin Sebor
- /* 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

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

2016-09-13 Thread Marek Polacek
For historical reasons, incrementing a boolean was allowed (because anything non-0 is true), while decrementing is forbidden. This has now changed, and since C++17 even ++ on bool is invalid. And C++ 03/11/14 [depr.incr.bool] says that ++ is deprecated, but we never diagnosed this. A bunch of