This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [C++ PATCH] Fix constexpr OBJ_TYPE_REF handling on array elts (PR c++/87398)


On Tue, Sep 25, 2018 at 10:57 AM, Jakub Jelinek <jakub@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 <jakub@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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]