Hi,
as also analyzed in the audit trail, we fail to produce the warning for
pointer to member function == 0 (those for assignments and
initializations are fine) for targets characterized by
TARGET_PTRMEMFUNC_VBIT_LOCATION == ptrmemfunc_vbit_in_delta, for the
obvious reason that in cp_build_binary_op we do not end up calling
cp_convert (with integer_zero_node as second argument) and then
cp_convert_to_pointer, something else entirely happens. But in
cp_build_binary_op we have all the information we need in this case,
thus the fix involves just doing the warning check here. I tried to
figure out whether we could do something else, less "dumb" so to speak,
but failed at that. Anyway, fix tested by me on x86_64-linux and both me
and Greta on arm-none-eabi.
Ok?
Thanks,
Paolo.
//////////////////
2011-11-22 Paolo Carlini <paolo.carl...@oracle.com>
PR c++/51196
* typeck.c (cp_build_binary_op, [case EQ_EXPR]): For targets having
TARGET_PTRMEMFUNC_VBIT_LOCATION == ptrmemfunc_vbit_in_delta, do here
the -Wzero-as-null-pointer-constant warning for pmf == 0.
Index: typeck.c
===================================================================
--- typeck.c (revision 181613)
+++ typeck.c (working copy)
@@ -4056,6 +4056,13 @@ cp_build_binary_op (location_t location,
delta0,
integer_one_node,
complain);
+
+ if ((complain & tf_warning)
+ && c_inhibit_evaluation_warnings == 0
+ && !NULLPTR_TYPE_P (TREE_TYPE (op1)))
+ warning (OPT_Wzero_as_null_pointer_constant,
+ "zero as null pointer constant");
+
e2 = cp_build_binary_op (location,
EQ_EXPR, e2, integer_zero_node,
complain);