Re: [C/C++ PATCH] Implement -Wshift-overflow (PR c++/55095) (take 3)

2015-07-22 Thread Marek Polacek
On Wed, Jul 22, 2015 at 07:48:47AM -0500, Segher Boessenkool wrote: > vmx.exp sets a bunch of options and the test overrides that now. Options > like -maltivec are pretty important for this test to work -- it #includes > altivec.h, which does #error unless -maltivec is set, and things go downhill

Re: [C/C++ PATCH] Implement -Wshift-overflow (PR c++/55095) (take 3)

2015-07-22 Thread Segher Boessenkool
On Wed, Jul 22, 2015 at 02:39:14PM +0200, Marek Polacek wrote: > On Wed, Jul 22, 2015 at 08:35:12AM -0400, David Edelsohn wrote: > > On Tue, Jul 21, 2015 at 5:59 AM, Marek Polacek wrote: > > > On Mon, Jul 20, 2015 at 04:23:08PM -0400, David Edelsohn wrote: > > >> This seems to have caused a number

Re: [C/C++ PATCH] Implement -Wshift-overflow (PR c++/55095) (take 3)

2015-07-22 Thread Marek Polacek
On Wed, Jul 22, 2015 at 08:35:12AM -0400, David Edelsohn wrote: > On Tue, Jul 21, 2015 at 5:59 AM, Marek Polacek wrote: > > On Mon, Jul 20, 2015 at 04:23:08PM -0400, David Edelsohn wrote: > >> This seems to have caused a number of new failures in the PPC > >> testsuite for vmx/unpack. > > > > Sorr

Re: [C/C++ PATCH] Implement -Wshift-overflow (PR c++/55095) (take 3)

2015-07-22 Thread David Edelsohn
On Tue, Jul 21, 2015 at 5:59 AM, Marek Polacek wrote: > On Mon, Jul 20, 2015 at 04:23:08PM -0400, David Edelsohn wrote: >> This seems to have caused a number of new failures in the PPC >> testsuite for vmx/unpack. > > Sorry about that. Should be fixed with this patch I'm about to commit. > > 2015

Re: [C/C++ PATCH] Implement -Wshift-overflow (PR c++/55095) (take 3)

2015-07-21 Thread Marek Polacek
On Mon, Jul 20, 2015 at 04:23:08PM -0400, David Edelsohn wrote: > This seems to have caused a number of new failures in the PPC > testsuite for vmx/unpack. Sorry about that. Should be fixed with this patch I'm about to commit. 2015-07-21 Marek Polacek * gcc.dg/vmx/unpack-be-order.c:

Re: [C/C++ PATCH] Implement -Wshift-overflow (PR c++/55095) (take 3)

2015-07-20 Thread David Edelsohn
This seems to have caused a number of new failures in the PPC testsuite for vmx/unpack. - David

Re: [C/C++ PATCH] Implement -Wshift-overflow (PR c++/55095) (take 3)

2015-07-20 Thread Marek Polacek
On Fri, Jul 17, 2015 at 03:51:33PM -0600, Jeff Law wrote: > I'll approve the C++ parts given how simple they are :-) Thanks, I've committed the patch now after another regtest/bootstrap. Marek

Re: [C/C++ PATCH] Implement -Wshift-overflow (PR c++/55095) (take 3)

2015-07-17 Thread Jeff Law
On 07/17/2015 02:09 AM, Marek Polacek wrote: Ping^6. On Fri, Jul 10, 2015 at 03:23:43PM +0200, Marek Polacek wrote: Ping^5. On Fri, Jul 03, 2015 at 09:42:39AM +0200, Marek Polacek wrote: Ping^4. On Fri, Jun 26, 2015 at 10:08:51AM +0200, Marek Polacek wrote: I'm pinging the C++ parts. On Fr

Re: [C/C++ PATCH] Implement -Wshift-overflow (PR c++/55095) (take 3)

2015-07-17 Thread Marek Polacek
Ping^6. On Fri, Jul 10, 2015 at 03:23:43PM +0200, Marek Polacek wrote: > Ping^5. > > On Fri, Jul 03, 2015 at 09:42:39AM +0200, Marek Polacek wrote: > > Ping^4. > > > > On Fri, Jun 26, 2015 at 10:08:51AM +0200, Marek Polacek wrote: > > > I'm pinging the C++ parts. > > > > > > On Fri, Jun 19, 201

Re: [C/C++ PATCH] Implement -Wshift-overflow (PR c++/55095) (take 3)

2015-07-10 Thread Marek Polacek
Ping^5. On Fri, Jul 03, 2015 at 09:42:39AM +0200, Marek Polacek wrote: > Ping^4. > > On Fri, Jun 26, 2015 at 10:08:51AM +0200, Marek Polacek wrote: > > I'm pinging the C++ parts. > > > > On Fri, Jun 19, 2015 at 12:44:36PM +0200, Marek Polacek wrote: > > > Ping. > > > > > > On Fri, Jun 12, 2015

Re: [C/C++ PATCH] Implement -Wshift-overflow (PR c++/55095) (take 3)

2015-07-03 Thread Marek Polacek
Ping^4. On Fri, Jun 26, 2015 at 10:08:51AM +0200, Marek Polacek wrote: > I'm pinging the C++ parts. > > On Fri, Jun 19, 2015 at 12:44:36PM +0200, Marek Polacek wrote: > > Ping. > > > > On Fri, Jun 12, 2015 at 11:07:29AM +0200, Marek Polacek wrote: > > > Ping. > > > > > > On Fri, Jun 05, 2015 at

Re: [C/C++ PATCH] Implement -Wshift-overflow (PR c++/55095) (take 3)

2015-06-26 Thread Marek Polacek
I'm pinging the C++ parts. On Fri, Jun 19, 2015 at 12:44:36PM +0200, Marek Polacek wrote: > Ping. > > On Fri, Jun 12, 2015 at 11:07:29AM +0200, Marek Polacek wrote: > > Ping. > > > > On Fri, Jun 05, 2015 at 10:55:08AM +0200, Marek Polacek wrote: > > > On Thu, Jun 04, 2015 at 09:04:19PM +, Jo

Re: [C/C++ PATCH] Implement -Wshift-overflow (PR c++/55095) (take 3)

2015-06-19 Thread Marek Polacek
Ping. On Fri, Jun 12, 2015 at 11:07:29AM +0200, Marek Polacek wrote: > Ping. > > On Fri, Jun 05, 2015 at 10:55:08AM +0200, Marek Polacek wrote: > > On Thu, Jun 04, 2015 at 09:04:19PM +, Joseph Myers wrote: > > > The C changes are OK. > > > > Jason, do you want to approve the C++ parts?

Re: [C/C++ PATCH] Implement -Wshift-overflow (PR c++/55095) (take 3)

2015-06-12 Thread Marek Polacek
Ping. On Fri, Jun 05, 2015 at 10:55:08AM +0200, Marek Polacek wrote: > On Thu, Jun 04, 2015 at 09:04:19PM +, Joseph Myers wrote: > > The C changes are OK. > > Jason, do you want to approve the C++ parts? > > Thanks, Marek

Re: [C/C++ PATCH] Implement -Wshift-overflow (PR c++/55095) (take 3)

2015-06-05 Thread Marek Polacek
On Thu, Jun 04, 2015 at 09:04:19PM +, Joseph Myers wrote: > The C changes are OK. Jason, do you want to approve the C++ parts? Thanks, Marek

Re: [C/C++ PATCH] Implement -Wshift-overflow (PR c++/55095) (take 3)

2015-06-04 Thread Joseph Myers
On Wed, 3 Jun 2015, Marek Polacek wrote: > > Well, ok then. This new version incorporates Richard S.'s suggestion, > > and warns even for 1 << 31 in C99/C11 (also in C90 when -Wshift-overflow > > is explicitely specified). For C++, it warns about 1 << 31 by default > > only in C++11 mode, in C++

Re: [C/C++ PATCH] Implement -Wshift-overflow (PR c++/55095) (take 3)

2015-06-03 Thread Marek Polacek
On Tue, Jun 02, 2015 at 09:25:32PM +0200, Marek Polacek wrote: > On Fri, May 29, 2015 at 08:49:58PM +, Joseph Myers wrote: > > On Mon, 25 May 2015, Marek Polacek wrote: > > > > > +/* Warn if signed left shift overflows. Note that we don't warn > > > + about left-shifting 1 into the sign bit

Re: [C/C++ PATCH] Implement -Wshift-overflow (PR c++/55095) (take 2)

2015-06-02 Thread Marek Polacek
On Fri, May 29, 2015 at 08:49:58PM +, Joseph Myers wrote: > On Mon, 25 May 2015, Marek Polacek wrote: > > > +/* Warn if signed left shift overflows. Note that we don't warn > > + about left-shifting 1 into the sign bit; cf. > > + > >

Re: [C/C++ PATCH] Implement -Wshift-overflow (PR c++/55095)

2015-06-02 Thread Marek Polacek
On Tue, Jun 02, 2015 at 09:53:14AM +0100, Richard Sandiford wrote: > unsigned int min_prec = (wi::min_precision (op0, SIGNED) > + TREE_INT_CST_LOW (op1)); > bool overflowed = min_prec > TYPE_PRECISION (type0); > if (overflowed && c_inhibit_evaluation_warnings == 0) >

Re: [C/C++ PATCH] Implement -Wshift-overflow (PR c++/55095)

2015-06-02 Thread Richard Sandiford
Richard Biener writes: > On Mon, Jun 1, 2015 at 10:06 PM, Richard Sandiford > wrote: >> Marek Polacek writes: >>> + /* Left-hand operand must be signed. */ >>> + if (TYPE_UNSIGNED (type0)) >>> +return false; >>> + >>> + /* Compute the result in infinite precision math (sort of). */ >>>

Re: [C/C++ PATCH] Implement -Wshift-overflow (PR c++/55095)

2015-06-02 Thread Richard Biener
On Mon, Jun 1, 2015 at 10:06 PM, Richard Sandiford wrote: > Marek Polacek writes: >> + /* Left-hand operand must be signed. */ >> + if (TYPE_UNSIGNED (type0)) >> +return false; >> + >> + /* Compute the result in infinite precision math (sort of). */ >> + widest_int w = wi::lshift (wi::t

Re: [C/C++ PATCH] Implement -Wshift-overflow (PR c++/55095)

2015-06-01 Thread Richard Sandiford
Marek Polacek writes: > + /* Left-hand operand must be signed. */ > + if (TYPE_UNSIGNED (type0)) > +return false; > + > + /* Compute the result in infinite precision math (sort of). */ > + widest_int w = wi::lshift (wi::to_widest (op0), wi::to_widest (op1)); > + unsigned int min_prec =

Re: [C/C++ PATCH] Implement -Wshift-overflow (PR c++/55095)

2015-05-29 Thread Joseph Myers
On Mon, 25 May 2015, Marek Polacek wrote: > +/* Warn if signed left shift overflows. Note that we don't warn > + about left-shifting 1 into the sign bit; cf. > + > + for C++ and

Re: [C/C++ PATCH] Implement -Wshift-overflow (PR c++/55095)

2015-05-26 Thread Marek Polacek
Since the move to C++14 is now imminent, I regtested/bootstrapped the patch with -Wshift-overflow always enabled for C++ and that went well. Marek

[C/C++ PATCH] Implement -Wshift-overflow (PR c++/55095)

2015-05-25 Thread Marek Polacek
Not sure how many packages I'll break this time around, so early testing appreciated. The C/C++ standards say that for signed left shift, if E1 x 2^{E2} isn't representable, the behavior is undefined. We didn't have a corresponding warning though, so this patch adds -Wshift-overflow, enabled by d