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: RFA: PATCH to make fold_indirect_ref_1 fold more things


On Fri, Oct 29, 2010 at 9:34 PM, Jason Merrill <jason@redhat.com> wrote:
> On 10/29/2010 11:25 AM, Richard Guenther wrote:
>>
>> So - what kind of testcases are you trying to handle? ?(the middle-end
>> will
>> optimize this stuff keeping TBAA info correct during forwprop)
>
> The RECORD_TYPE folding was for this testcase:
>
> struct C { // literal type
> ?int m;
> ?int n;
> ?constexpr C(int m) : m(m), n(-m) {}
> ?constexpr bool is_neg() { return m < 0; }
> };
>
> constexpr bool check1(const C& c, int C:: *pm) { return c.*pm < 0; } // #1
>
> constexpr bool check2(const C* pc, bool (C::*pm)() const) { return
> (pc->*pm)(); } // #2
>
> constexpr C c(-1);
>
> static_assert(!check1(c, &C::n), "Error");
> static_assert(check1(c, &C::m), "Error");
>
> static_assert(check2(&c, &C::is_neg), "Error");
>
> For constexpr we need to evaluate suitable constant expressions at parsing
> time so that we can use them as template arguments, array bounds and such
> like.
>
> I guess I can just do this folding in the constexpr expander...

Yeah, I think that should be safer.

Richard.

> Jason
>


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