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,
+                         OPT_Waddress,
+                         "the address of reference %qD may be assumed to "
+                         "always evaluate to %<true%>",
+                         inner);

Perhaps "the compiler can assume that the address of reference %qD will always evaluate to %<true%>"?

-         if (TREE_CODE (op0) == ADDR_EXPR
+         if ((TREE_CODE (op0) == ADDR_EXPR
+              || (CONVERT_EXPR_P (op0)
+                  && TREE_CODE (TREE_TYPE (TREE_OPERAND (op0, 0)))
+                     == REFERENCE_TYPE))
              && decl_with_nonnull_addr_p (TREE_OPERAND (op0, 0)))
            {
              if ((complain & tf_warning)
@@ -4437,7 +4440,10 @@ cp_build_binary_op (location_t location,
          else
            result_type = type1;

-         if (TREE_CODE (op1) == ADDR_EXPR
+         if ((TREE_CODE (op1) == ADDR_EXPR
+              || (CONVERT_EXPR_P (op1)
+                  && TREE_CODE (TREE_TYPE (TREE_OPERAND (op1, 0)))
+                     == REFERENCE_TYPE))

Let's distinguish between address of object vs reference in these warnings, too.

Jason

Reply via email to