Re: [PATCH] Emit -Waddress warnings for comparing address of reference against NULL

2015-06-11 Thread Jason Merrill
Let's use explicit location for the C++ front end warnings, too. OK with that change. Jason

Re: [PATCH] Emit -Waddress warnings for comparing address of reference against NULL

2015-06-09 Thread Patrick Palka
On Sun, May 3, 2015 at 5:29 PM, Patrick Palka wrote: > On Sun, Apr 26, 2015 at 8:56 PM, Patrick Palka wrote: >> Here is an updated version of the patch with, hopefully, all your >> suggestions made. I decided to add calls to STRIP_NOPS before emitting >> the warning so that we properly warn for

Re: [PATCH] Emit -Waddress warnings for comparing address of reference against NULL

2015-05-03 Thread Patrick Palka
On Sun, Apr 26, 2015 at 8:56 PM, Patrick Palka wrote: > Here is an updated version of the patch with, hopefully, all your > suggestions made. I decided to add calls to STRIP_NOPS before emitting > the warning so that we properly warn for cases where there's a cast in > between the whole thing, e.

[PATCH] Emit -Waddress warnings for comparing address of reference against NULL

2015-04-26 Thread Patrick Palka
Here is an updated version of the patch with, hopefully, all your suggestions made. I decided to add calls to STRIP_NOPS before emitting the warning so that we properly warn for cases where there's a cast in between the whole thing, e.g. if (!&(int &)a) I also added guards to emit the warnings

Re: Re: [PATCH] Emit -Waddress warnings for comparing address of reference against NULL

2015-04-23 Thread Patrick Palka
On Thu, Apr 23, 2015 at 11:34 AM, Manuel López-Ibáñez wrote: > On 04/23/2015 05:12 PM, Jason Merrill wrote: >> >> On 04/20/2015 10:36 PM, Patrick Palka wrote: >> Implementation is pretty straightforward. The only catch is that the >> middle-end doesn't actually assume that REFERENCE_TYPEs are non

Re: [PATCH] Emit -Waddress warnings for comparing address of reference against NULL

2015-04-23 Thread Jason Merrill
On 04/23/2015 11:34 AM, Manuel López-Ibáñez wrote: It seems also weird we do not warn directly for '*(int *)0' in the C/C++ FE. Agreed. Using decl_with_nonnull_addr_p doesn't make sense for reference variables, since we're using their pointer value rather than their address. Is an extra che

Re: Re: [PATCH] Emit -Waddress warnings for comparing address of reference against NULL

2015-04-23 Thread Manuel López-Ibáñez
On 04/23/2015 05:12 PM, Jason Merrill wrote: On 04/20/2015 10:36 PM, Patrick Palka wrote: Implementation is pretty straightforward. The only catch is that the middle-end doesn't actually assume that REFERENCE_TYPEs are non-NULL so code like int &a = *(int *)0; if (&a != 0) will warn th

Re: [PATCH] Emit -Waddress warnings for comparing address of reference against NULL

2015-04-23 Thread Jason Merrill
On 04/20/2015 10:36 PM, Patrick Palka wrote: + if (decl_with_nonnull_addr_p (inner)) Using decl_with_nonnull_addr_p doesn't make sense for reference variables, since we're using their pointer value rather than their address. + warning_at (location, +

[PATCH] Emit -Waddress warnings for comparing address of reference against NULL

2015-04-20 Thread Patrick Palka
Implementation is pretty straightforward. The only catch is that the middle-end doesn't actually assume that REFERENCE_TYPEs are non-NULL so code like int &a = *(int *)0; if (&a != 0) will warn that &a will never be NULL yet the middle-end will fold the conditional to false instead of tr