On Sun, Jan 10, 2016 at 10:19 PM, Patrick Palka <patr...@parcs.ath.cx> wrote: > On Mon, Dec 21, 2015 at 6:07 PM, Patrick Palka <patr...@parcs.ath.cx> wrote: >> We are currently failing to fold equality comparisons involving >> PTRMEM_CSTs since (I think) r229018 thus making this a GCC 6 regression. >> This regression shows up in the boost testsuite. >> >> Fixed in a straightforward way. OK to commit after bootstrap + regtest? >> >> gcc/cp/ChangeLog: >> >> * constexpr.c (cxx_eval_binary_expression): Expand >> the PTRMEM_CST operands of an equality comparison. >> >> gcc/testsuite/ChangeLog: >> >> * g++.dg/cpp0x/constexpr-ptrmem5.C: New test. >> --- >> gcc/cp/constexpr.c | 9 +++++++++ >> gcc/testsuite/g++.dg/cpp0x/constexpr-ptrmem5.C | 14 ++++++++++++++ >> 2 files changed, 23 insertions(+) >> create mode 100644 gcc/testsuite/g++.dg/cpp0x/constexpr-ptrmem5.C >> >> diff --git a/gcc/cp/constexpr.c b/gcc/cp/constexpr.c >> index 208f43b..1ad87aa 100644 >> --- a/gcc/cp/constexpr.c >> +++ b/gcc/cp/constexpr.c >> @@ -1630,6 +1630,15 @@ cxx_eval_binary_expression (const constexpr_ctx *ctx, >> tree t, >> location_t loc = EXPR_LOCATION (t); >> enum tree_code code = TREE_CODE (t); >> tree type = TREE_TYPE (t); >> + >> + if (code == EQ_EXPR || code == NE_EXPR) >> + { >> + if (TREE_CODE (lhs) == PTRMEM_CST && CONSTANT_CLASS_P (rhs)) >> + lhs = cplus_expand_constant (lhs); >> + if (TREE_CODE (rhs) == PTRMEM_CST && CONSTANT_CLASS_P (lhs)) >> + rhs = cplus_expand_constant (rhs); >> + } >> + >> r = fold_binary_loc (loc, code, type, lhs, rhs); >> if (r == NULL_TREE) >> { >> diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-ptrmem5.C >> b/gcc/testsuite/g++.dg/cpp0x/constexpr-ptrmem5.C >> new file mode 100644 >> index 0000000..e28c917 >> --- /dev/null >> +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-ptrmem5.C >> @@ -0,0 +1,14 @@ >> +// { dg-do compile { target c++11 } } >> + >> +#define SA(x) static_assert ((x), #x) >> + >> +struct X { int a, b; }; >> + >> +void >> +foo () >> +{ >> + SA (&X::a); >> + SA (&X::a == &X::a); >> + SA (&X::a != &X::b); >> + SA ((!&X::b) == 0); >> +} >> -- >> 2.7.0.rc0.50.g1470d8f.dirty >> > > Ping.
Ping.