Message ID | 515C68EC.9030902@oracle.com |
---|---|
State | New |
Headers | show |
.. I analyzed a bit what is happening and this is what I see: the only interesting case is that of C++, where pointer_int_sum is called via cp_pointer_int_sum. The latter is only called by cp_build_binary_op but that happens for MINUS_EXPR and PLUS_EXPR as operator. In such cases however, only operands with POINTER_TYPE as TREE_TYPE are passed to cp_pointer_int_sum. AFAICS this never happens for actual pointers to (non-static) member function, eg, for: struct A { void f(); }; auto p = &A::f + 1; the TREE_TYPE of the first operand is RECORD_TYPE (the TREE_CODE is PTRMEM_CST). On the other hand, for static member functions the representation uses as TREE_TYPE a POINTER_TYPE to FUNCTION_TYPE, which is correctly handled by pointer_int_sum. Paolo.
Ok. Jason
Index: c-common.c =================================================================== --- c-common.c (revision 197432) +++ c-common.c (working copy) @@ -4290,12 +4290,6 @@ pointer_int_sum (location_t loc, enum tree_code re "pointer to a function used in arithmetic"); size_exp = integer_one_node; } - else if (TREE_CODE (TREE_TYPE (result_type)) == METHOD_TYPE) - { - pedwarn (loc, pedantic ? OPT_Wpedantic : OPT_Wpointer_arith, - "pointer to member function used in arithmetic"); - size_exp = integer_one_node; - } else size_exp = size_in_bytes (TREE_TYPE (result_type));