diff options
author | Jason Merrill <jason@redhat.com> | 2020-06-23 21:25:21 -0400 |
---|---|---|
committer | Jason Merrill <jason@redhat.com> | 2020-06-24 16:02:27 -0400 |
commit | 554eb7d2e1ef5660d6a8e1c12ee1d751a70bbf31 (patch) | |
tree | c09f5e81907b33dfe26a9e11d56885a69269d8c8 /gcc/cp | |
parent | 053ba9ec74722c938aa37699f458c0d748333315 (diff) | |
download | gcc-554eb7d2e1ef5660d6a8e1c12ee1d751a70bbf31.zip gcc-554eb7d2e1ef5660d6a8e1c12ee1d751a70bbf31.tar.gz gcc-554eb7d2e1ef5660d6a8e1c12ee1d751a70bbf31.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.
(cherry picked from commit 7d6baf68fe22b6ef5b1d6fabbef97c0e1b4d7abf)
Diffstat (limited to 'gcc/cp')
-rw-r--r-- | gcc/cp/call.c | 6 | ||||
-rw-r--r-- | gcc/cp/class.c | 4 |
2 files changed, 9 insertions, 1 deletions
diff --git a/gcc/cp/call.c b/gcc/cp/call.c index a226a5c..b21569a 100644 --- a/gcc/cp/call.c +++ b/gcc/cp/call.c @@ -8696,7 +8696,11 @@ build_over_call (struct z_candidate *cand, int flags, tsubst_flags_t complain) if (DECL_VINDEX (fn) && (flags & LOOKUP_NONVIRTUAL) == 0 && resolves_to_fixed_type_p (arg)) { - fn = lookup_vfn_in_binfo (DECL_VINDEX (fn), cand->conversion_path); + tree binfo = cand->conversion_path; + if (BINFO_TYPE (binfo) != DECL_CONTEXT (fn)) + binfo = lookup_base (binfo, DECL_CONTEXT (fn), ba_unique, + NULL, complain); + fn = lookup_vfn_in_binfo (DECL_VINDEX (fn), binfo); flags |= LOOKUP_NONVIRTUAL; } diff --git a/gcc/cp/class.c b/gcc/cp/class.c index 3e2e2c7..08d3b37 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)); } |