This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [C++ Patch / RFC] Tidy c-common.c:pointer_int_sum?


.. 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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]