https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101597

--- Comment #4 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
I guess the problem is that for the middle-end, pointer conversions are
considered useless (with the small exceptions or different address spaces and
function/method vs. object pointers or if the pointers have different
TYPE_MODE),
so trying to figure out something from the type of OBJ_TYPE_REF's
OBJ_TYPE_REF_OBJECT operand is wrong.
So, either we want to print something ugly, e.g. with obj_type_ref in it
somewhere, if !virtual_method_call_p (t, true), or perhaps could change aall
the spots that create OBJ_TYPE_REFs such that the OBJ_TYPE_REF_TOKEN which I
think must be INTEGER_CST wouldn't have integer_type_node type, but would
actually have
the original type of the second argument of OBJ_TYPE_REF.
E.g. in build_vfn_ref instead of doing
  aref = build3 (OBJ_TYPE_REF, TREE_TYPE (aref), aref, instance_ptr, idx);
do
  aref = build3 (OBJ_TYPE_REF, TREE_TYPE (aref), aref, instance_ptr,
                 fold_convert (TREE_TYPE (instance_ptr), idx));
or so and use that for resolve_virtual_fun_from_obj_type_ref purposes.
It would be similar to what we do e.g. with MEM_REFs.
Devirtualization and constexpr virtual call handling would need to be verified
for that change of course.

Reply via email to