Re: PR c/16351 Extend Wnonnull for returns_nonnull

2015-07-25 Thread Bernhard Reutner-Fischer
On July 25, 2015 1:15:21 AM GMT+02:00, Trevor Saunders wrote: > >Another case is > >Foo * >bar() >{ > #if SHOULD_USE_BAR > ... >#else > return NULL; >#endif >} > >And somehow your program is setup so bar is only called when >SHOULD_USE_BAR is defined. In that sort of case it may be convenien

Re: PR c/16351 Extend Wnonnull for returns_nonnull

2015-07-24 Thread Jeff Law
On 07/24/2015 05:15 PM, Trevor Saunders wrote: Moreover, this warning works in exactly the same cases as __attribute__((nonnull)) does for function arguments, and so far those haven't been a source of false positives. I'm sure I could write one ;-) And given that a FE based version of this w

Re: PR c/16351 Extend Wnonnull for returns_nonnull

2015-07-24 Thread Jeff Law
On 07/24/2015 04:41 PM, Manuel López-Ibáñez wrote: On 25 July 2015 at 00:17, Patrick Palka wrote: On Fri, Jul 24, 2015 at 5:55 PM, Manuel López-Ibáñez wrote: Is there a PR for this particular test case? I am interested in improving the uninit analysis for gcc 6 so this potentially seems up my

Re: PR c/16351 Extend Wnonnull for returns_nonnull

2015-07-24 Thread Jeff Law
On 07/24/2015 04:17 PM, Patrick Palka wrote: On Fri, Jul 24, 2015 at 5:55 PM, Manuel López-Ibáñez wrote: On 24 July 2015 at 21:30, Jeff Law wrote: On 07/24/2015 07:45 AM, Manuel López-Ibáñez wrote: On 23 July 2015 at 19:43, Jeff Law wrote: Warning in the front-ends like this can generate

Re: PR c/16351 Extend Wnonnull for returns_nonnull

2015-07-24 Thread Jeff Law
On 07/24/2015 03:55 PM, Manuel López-Ibáñez wrote: I think it is also a matter of the particular warning and on the balance of true positives vs. false positives in typical code-bases. In this case, returning NULL in any code-path from a returns_nonnull function, even if the path is currently un

Re: PR c/16351 Extend Wnonnull for returns_nonnull

2015-07-24 Thread Manuel López-Ibáñez
On 25 July 2015 at 01:15, Trevor Saunders wrote: > I'd actually expect reasonable cases to be fairly common. For example I added it to -Wall, I guess we'll see... not sure how many users of returns_nonnull are out there. In all your cases there is no reason to prefer NULL rather than, say, (T*)

Re: PR c/16351 Extend Wnonnull for returns_nonnull

2015-07-24 Thread Trevor Saunders
On Fri, Jul 24, 2015 at 11:55:23PM +0200, Manuel López-Ibáñez wrote: > On 24 July 2015 at 21:30, Jeff Law wrote: > > On 07/24/2015 07:45 AM, Manuel López-Ibáñez wrote: > >> > >> On 23 July 2015 at 19:43, Jeff Law wrote: > >>> > >>> Warning in the front-ends like this can generate false positives

Re: PR c/16351 Extend Wnonnull for returns_nonnull

2015-07-24 Thread Manuel López-Ibáñez
On 25 July 2015 at 00:17, Patrick Palka wrote: > On Fri, Jul 24, 2015 at 5:55 PM, Manuel López-Ibáñez > wrote: > Is there a PR for this particular test case? I am interested in > improving the uninit analysis for gcc 6 so this potentially seems up > my alley. We do not warn because of the infam

Re: PR c/16351 Extend Wnonnull for returns_nonnull

2015-07-24 Thread Patrick Palka
On Fri, Jul 24, 2015 at 5:55 PM, Manuel López-Ibáñez wrote: > On 24 July 2015 at 21:30, Jeff Law wrote: >> On 07/24/2015 07:45 AM, Manuel López-Ibáñez wrote: >>> >>> On 23 July 2015 at 19:43, Jeff Law wrote: Warning in the front-ends like this can generate false positives (such as

Re: PR c/16351 Extend Wnonnull for returns_nonnull

2015-07-24 Thread Manuel López-Ibáñez
On 24 July 2015 at 21:30, Jeff Law wrote: > On 07/24/2015 07:45 AM, Manuel López-Ibáñez wrote: >> >> On 23 July 2015 at 19:43, Jeff Law wrote: >>> >>> Warning in the front-ends like this can generate false positives (such as >>> a >>> NULL return in an unreachable path and miss cases where the NU

Re: PR c/16351 Extend Wnonnull for returns_nonnull

2015-07-24 Thread Jeff Law
On 07/24/2015 07:45 AM, Manuel López-Ibáñez wrote: On 23 July 2015 at 19:43, Jeff Law wrote: Warning in the front-ends like this can generate false positives (such as a NULL return in an unreachable path and miss cases where the NULL has to be propagated into the return by later optimizations.

Re: PR c/16351 Extend Wnonnull for returns_nonnull

2015-07-24 Thread Jeff Law
On 07/24/2015 02:06 AM, Bernhard Reutner-Fischer wrote: Looking at the reduced testcase in that PR, I'm pretty sure its a bogus reduction. Yes, the original, smallish test case in comment #4 is different, AFAICS. Agreed. I should have been a bit more explicit. The test in c#5 is not a vali

Re: PR c/16351 Extend Wnonnull for returns_nonnull

2015-07-24 Thread Manuel López-Ibáñez
On 23 July 2015 at 19:43, Jeff Law wrote: > Warning in the front-ends like this can generate false positives (such as a > NULL return in an unreachable path and miss cases where the NULL has to be > propagated into the return by later optimizations. False positives (for the warning as proposed ri

Re: PR c/16351 Extend Wnonnull for returns_nonnull

2015-07-24 Thread Bernhard Reutner-Fischer
On July 24, 2015 7:30:03 AM GMT+02:00, Jeff Law wrote: >On 07/23/2015 04:44 PM, Bernhard Reutner-Fischer wrote: >> On July 23, 2015 7:43:51 PM GMT+02:00, Jeff Law >wrote: >>> On 07/22/2015 09:29 AM, Manuel López-Ibáñez wrote: While looking at PR c/16351, I noticed that all tests proposed for

Re: PR c/16351 Extend Wnonnull for returns_nonnull

2015-07-23 Thread Jeff Law
On 07/23/2015 04:44 PM, Bernhard Reutner-Fischer wrote: On July 23, 2015 7:43:51 PM GMT+02:00, Jeff Law wrote: On 07/22/2015 09:29 AM, Manuel López-Ibáñez wrote: While looking at PR c/16351, I noticed that all tests proposed for -Wnull-attribute (https://gcc.gnu.org/ml/gcc-patches/2014-01/msg0

Re: PR c/16351 Extend Wnonnull for returns_nonnull

2015-07-23 Thread Bernhard Reutner-Fischer
On July 23, 2015 7:43:51 PM GMT+02:00, Jeff Law wrote: >On 07/22/2015 09:29 AM, Manuel López-Ibáñez wrote: >> While looking at PR c/16351, I noticed that all tests proposed for >> -Wnull-attribute >> (https://gcc.gnu.org/ml/gcc-patches/2014-01/msg01715.html) could be >> warned from the FEs by simp

Re: PR c/16351 Extend Wnonnull for returns_nonnull

2015-07-23 Thread Jeff Law
On 07/22/2015 09:29 AM, Manuel López-Ibáñez wrote: While looking at PR c/16351, I noticed that all tests proposed for -Wnull-attribute (https://gcc.gnu.org/ml/gcc-patches/2014-01/msg01715.html) could be warned from the FEs by simply extending the existing Wnonnull. Bootstrapped and regression te

PR c/16351 Extend Wnonnull for returns_nonnull

2015-07-22 Thread Manuel López-Ibáñez
While looking at PR c/16351, I noticed that all tests proposed for -Wnull-attribute (https://gcc.gnu.org/ml/gcc-patches/2014-01/msg01715.html) could be warned from the FEs by simply extending the existing Wnonnull. Bootstrapped and regression tested on x86_64-linux-gnu. OK? gcc/ChangeLog: 2015