summaryrefslogtreecommitdiff
path: root/gcc/cp/class.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/cp/class.c')
-rw-r--r--gcc/cp/class.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/gcc/cp/class.c b/gcc/cp/class.c
index bab15524a60..ca492cdbd40 100644
--- a/gcc/cp/class.c
+++ b/gcc/cp/class.c
@@ -729,9 +729,13 @@ build_vtbl_ref (tree instance, tree idx)
tree
build_vfn_ref (tree instance_ptr, tree idx)
{
- tree aref;
+ tree obtype = TREE_TYPE (TREE_TYPE (instance_ptr));
+
+ /* Leave the INDIRECT_REF unfolded so cp_ubsan_maybe_instrument_member_call
+ can find instance_ptr. */
+ tree ind = build1 (INDIRECT_REF, obtype, instance_ptr);
- aref = build_vtbl_ref (cp_build_fold_indirect_ref (instance_ptr), idx);
+ tree aref = build_vtbl_ref (ind, idx);
/* When using function descriptors, the address of the
vtable entry is treated as a function pointer. */