On 01/22/2016 05:07 PM, Marek Polacek wrote:
On Fri, Jan 22, 2016 at 03:38:26PM -0500, Jason Merrill wrote:
If we have a NOP_EXPR to the same type, we should strip it here.
This helps for the unreduced testcases in the PR, but not for the reduced one,
because for the reduced one, the types are not the same. One type is
struct
{
void Dict::<T461> (struct Dict *, T) * __pfn;
long int __delta;
}
and the second one
struct
{
void Dict::<T442> (struct Dict *) * __pfn;
long int __delta;
}
The NOP_EXPR in this case originated in build_reinterpret_cast_1:
7070 else if ((TYPE_PTRFN_P (type) && TYPE_PTRFN_P (intype))
7071 || (TYPE_PTRMEMFUNC_P (type) && TYPE_PTRMEMFUNC_P (intype)))
7072 return build_nop (type, expr);
Well, a reinterpret_cast makes the expression non-constant, so we can
recognize that case (when the types are unrelated) and bail out. After
that we probably still need to deal with the case of conversion to a
pointer-to-member-of-base type; for functions it looks like we can just
copy the PTRMEM_CST and give it a different type, but for data members I
think we'll need to add support for the type not matching the member in
expand_ptrmem_cst.
Jason