aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp/class.c
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2020-06-23 21:25:21 -0400
committerJason Merrill <jason@redhat.com>2020-06-24 15:59:20 -0400
commit7d6baf68fe22b6ef5b1d6fabbef97c0e1b4d7abf (patch)
tree676456440a072d575814e75d8b37421aeeb30565 /gcc/cp/class.c
parent0c586913e61021681e3221e8760cd87b24142aea (diff)
downloadgcc-7d6baf68fe22b6ef5b1d6fabbef97c0e1b4d7abf.zip
gcc-7d6baf68fe22b6ef5b1d6fabbef97c0e1b4d7abf.tar.gz
gcc-7d6baf68fe22b6ef5b1d6fabbef97c0e1b4d7abf.tar.bz2
c++: Fix ICE with using and virtual function. [PR95719]
conversion_path points to the base where we found the using-declaration, not where the function is actually a member; look up the actual base. And then maybe look back to the derived class if the base is primary. gcc/cp/ChangeLog: PR c++/95719 * call.c (build_over_call): Look up the overrider in base_binfo. * class.c (lookup_vfn_in_binfo): Look through BINFO_PRIMARY_P. gcc/testsuite/ChangeLog: PR c++/95719 * g++.dg/tree-ssa/final4.C: New test.
Diffstat (limited to 'gcc/cp/class.c')
-rw-r--r--gcc/cp/class.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/gcc/cp/class.c b/gcc/cp/class.c
index 629d27d..94a9585 100644
--- a/gcc/cp/class.c
+++ b/gcc/cp/class.c
@@ -2455,6 +2455,10 @@ lookup_vfn_in_binfo (tree idx, tree binfo)
int ix = tree_to_shwi (idx);
if (TARGET_VTABLE_USES_DESCRIPTORS)
ix /= MAX (TARGET_VTABLE_USES_DESCRIPTORS, 1);
+ while (BINFO_PRIMARY_P (binfo))
+ /* BINFO_VIRTUALS in a primary base isn't accurate, find the derived
+ class that actually owns the vtable. */
+ binfo = BINFO_INHERITANCE_CHAIN (binfo);
tree virtuals = BINFO_VIRTUALS (binfo);
return TREE_VALUE (chain_index (ix, virtuals));
}