This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [C++ Patch / RFC] Tidy c-common.c:pointer_int_sum?
- From: Paolo Carlini <paolo dot carlini at oracle dot com>
- To: "gcc-patches at gcc dot gnu dot org" <gcc-patches at gcc dot gnu dot org>
- Cc: Jason Merrill <jason at redhat dot com>
- Date: Wed, 03 Apr 2013 22:39:21 +0200
- Subject: Re: [C++ Patch / RFC] Tidy c-common.c:pointer_int_sum?
- References: <515C68EC dot 9030902 at oracle dot com>
.. 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.