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
> >+warn_for_null_address (location_t location, tree op, tsubst_flags_t 
> >complain)
> >+{
> ...
> >+  if (TREE_CODE (cop) == ADDR_EXPR
> >+      && decl_with_nonnull_addr_p (TREE_OPERAND (cop, 0))
> >+      && !TREE_NO_WARNING (cop))
> >+    warning_at (location, OPT_Waddress, "the address of %qD will never "
> >+            "be NULL", TREE_OPERAND (cop, 0));
> >+
> >+  if (CONVERT_EXPR_P (op)
> >+      && TREE_CODE (TREE_TYPE (TREE_OPERAND (op, 0))) == REFERENCE_TYPE)
> >+    {
> >+      tree inner_op = op;
> >+      STRIP_NOPS (inner_op);
> >+
> >+      if (DECL_P (inner_op))
> >+    warning_at (location, OPT_Waddress,
> >+                "the compiler can assume that the address of "
> >+                "%qD will never be NULL", inner_op);
> 
> Since I noted the subtle differences between the phrasing of
> the various -Waddress warnings in the bug, I have to ask: what is
> the significance of the difference between the two warnings here?
 
Quite frankly, I don't know.

> Would it not be appropriate to issue the first warning in the latter
> case?  Or perhaps even use the same text as is already used elsewhere:
> "the address of %qD will always evaluate as ‘true’" (since it may not
> be the macro NULL that's mentioned in the expression).

There are more discrepancies in the front ends wrt error/warning messages.
Perhaps we should try to unify them some more, but I don't think this has
a big priority, if the message is clear enough for the users.

        Marek

Reply via email to