Re: C++ PATCH to fix missing warning (PR c++/70194)

2016-03-20 Thread Jeff Law
On 03/16/2016 06:43 PM, Martin Sebor wrote: @@ -3974,6 +3974,38 @@ build_vec_cmp (tree_code code, tree type, return build3 (VEC_COND_EXPR, type, cmp, minus_one_vec, zero_vec); } +/* Possibly warn about an address never being NULL. */ + +static void +warn_for_null_address (location_t

Re: C++ PATCH to fix missing warning (PR c++/70194)

2016-03-19 Thread Martin Sebor
On 03/17/2016 10:48 AM, Patrick Palka wrote: On Thu, Mar 17, 2016 at 12:27 PM, Jeff Law wrote: On 03/16/2016 06:43 PM, Martin Sebor wrote: @@ -3974,6 +3974,38 @@ build_vec_cmp (tree_code code, tree type, return build3 (VEC_COND_EXPR, type, cmp, minus_one_vec, zero_vec);

Re: C++ PATCH to fix missing warning (PR c++/70194)

2016-03-19 Thread Jeff Law
On 03/17/2016 10:45 AM, Jason Merrill wrote: On 03/16/2016 08:43 PM, Martin Sebor wrote: @@ -3974,6 +3974,38 @@ build_vec_cmp (tree_code code, tree type, return build3 (VEC_COND_EXPR, type, cmp, minus_one_vec, zero_vec); } +/* Possibly warn about an address never being NULL. */ +

Re: C++ PATCH to fix missing warning (PR c++/70194)

2016-03-19 Thread Martin Sebor
While I would find the warning less misleading if it simply said in all three cases: "the address of 'x' will always evaluate as ‘true’" I think it would be even more accurate if it said "the address of 'x' may be assumed to evaluate to ‘true’" That avoids making claims about whether or not it

Re: C++ PATCH to fix missing warning (PR c++/70194)

2016-03-19 Thread Jason Merrill
On 03/16/2016 08:43 PM, Martin Sebor wrote: @@ -3974,6 +3974,38 @@ build_vec_cmp (tree_code code, tree type, return build3 (VEC_COND_EXPR, type, cmp, minus_one_vec, zero_vec); } +/* Possibly warn about an address never being NULL. */ + +static void +warn_for_null_address (location_t

Re: C++ PATCH to fix missing warning (PR c++/70194)

2016-03-19 Thread Marek Polacek
On Wed, Mar 16, 2016 at 06:43:39PM -0600, Martin Sebor wrote: > >@@ -3974,6 +3974,38 @@ build_vec_cmp (tree_code code, tree type, > >return build3 (VEC_COND_EXPR, type, cmp, minus_one_vec, zero_vec); > > } > > > >+/* Possibly warn about an address never being NULL. */ > >+ > >+static void >

Re: C++ PATCH to fix missing warning (PR c++/70194)

2016-03-19 Thread Jason Merrill
On 03/17/2016 02:51 PM, Martin Sebor wrote: On 03/17/2016 10:48 AM, Patrick Palka wrote: On Thu, Mar 17, 2016 at 12:27 PM, Jeff Law wrote: On 03/16/2016 06:43 PM, Martin Sebor wrote: @@ -3974,6 +3974,38 @@ build_vec_cmp (tree_code code, tree type, return build3

Re: C++ PATCH to fix missing warning (PR c++/70194)

2016-03-19 Thread Jason Merrill
OK. Jason

Re: C++ PATCH to fix missing warning (PR c++/70194)

2016-03-19 Thread Marek Polacek
On Tue, Mar 15, 2016 at 03:41:52PM -0400, Jason Merrill wrote: > Let's factor out that duplicated code into a separate function. Sure. It also allowed me to hoist the cheap tests for both warnings, and while at it, I used 'location' for the first warning. Bootstrapped/regtested on x86_64-linux,

Re: C++ PATCH to fix missing warning (PR c++/70194)

2016-03-18 Thread Patrick Palka
On Thu, Mar 17, 2016 at 12:27 PM, Jeff Law wrote: > On 03/16/2016 06:43 PM, Martin Sebor wrote: >>> >>> @@ -3974,6 +3974,38 @@ build_vec_cmp (tree_code code, tree type, >>> return build3 (VEC_COND_EXPR, type, cmp, minus_one_vec, zero_vec); >>> } >>> >>> +/* Possibly warn

Re: C++ PATCH to fix missing warning (PR c++/70194)

2016-03-18 Thread Martin Sebor
@@ -3974,6 +3974,38 @@ build_vec_cmp (tree_code code, tree type, return build3 (VEC_COND_EXPR, type, cmp, minus_one_vec, zero_vec); } +/* Possibly warn about an address never being NULL. */ + +static void +warn_for_null_address (location_t location, tree op, tsubst_flags_t complain) +{

Re: C++ PATCH to fix missing warning (PR c++/70194)

2016-03-15 Thread Jason Merrill
Let's factor out that duplicated code into a separate function. Jason

Re: C++ PATCH to fix missing warning (PR c++/70194)

2016-03-15 Thread Marek Polacek
On Tue, Mar 15, 2016 at 11:56:18AM +0100, Jakub Jelinek wrote: > From compile time perspective, I wonder if it wouldn't be better to do > the cheap tests early, like: > if (warn_address > && (complain & tf_warning) > && c_inhibit_evaluation_warnings == 0 > &&

Re: C++ PATCH to fix missing warning (PR c++/70194)

2016-03-15 Thread Jakub Jelinek
On Tue, Mar 15, 2016 at 11:41:20AM +0100, Marek Polacek wrote: > This is to fix missing "address of %qD will never be NULL" warning that went > away since the delayed folding merge. The problem was that cp_build_binary_op > was getting unfolded ops so in the constexpr case it saw "(int *) p"

C++ PATCH to fix missing warning (PR c++/70194)

2016-03-15 Thread Marek Polacek
This is to fix missing "address of %qD will never be NULL" warning that went away since the delayed folding merge. The problem was that cp_build_binary_op was getting unfolded ops so in the constexpr case it saw "(int *) p" instead of "" (in this particular testcase). Fixed by calling