On Tue, Sep 25, 2018 at 10:57 AM, Jakub Jelinek <ja...@redhat.com> wrote: > On Tue, Sep 25, 2018 at 10:42:08AM -0400, Jason Merrill wrote: >> On Tue, Sep 25, 2018 at 3:17 AM, Jakub Jelinek <ja...@redhat.com> wrote: >> > ARRAY_REF is a handled component, so when a virtual call is on an array >> > element (or some component thereof), the loop to look through handled >> > components will look through the ARRAY_REFs too and then TREE_TYPE (obj) >> > might be an ARRAY_TYPE. The code wants to look at the class type instead >> > though. >> >> Yeah, I think looping through handled components is wrong here; given >> something like >> >> struct A >> { >> virtual void f(); >> }; >> >> struct B >> { >> A a; >> } b; >> >> int main() >> { >> b.a.f(); >> } >> >> Looking through all handled components would give us "b", which has no >> virtual functions. > > You're right. So like this (only look through COMPONENT_REFs where the > FIELD_DECL is DECL_FIELD_IS_BASE)? > Only checked > make check-c++-all RUNTESTFLAGS="dg.exp='constexpr-virt* pr87398*'" > so far, but it also fixes the PR87425 testcase and doesn't regress anything.
Looks good. Jason