diff options
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/cp/ChangeLog | 4 | ||||
-rw-r--r-- | gcc/cp/constexpr.c | 4 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/cpp0x/constexpr-ptrmem6.C | 13 |
3 files changed, 21 insertions, 0 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index be223f2..78487ea 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,9 @@ 2016-07-21 Jason Merrill <jason@redhat.com> + PR c++/71896 + * constexpr.c (cxx_eval_binary_expression): Handle comparison + between lowered and unlowered PTRMEM_CST. + PR c++/65168 * typeck.c (cp_truthvalue_conversion): Compare pointers to nullptr. Don't set c_inhibit_evaluation_warnings. diff --git a/gcc/cp/constexpr.c b/gcc/cp/constexpr.c index 346fdfa..240c606 100644 --- a/gcc/cp/constexpr.c +++ b/gcc/cp/constexpr.c @@ -1838,6 +1838,10 @@ cxx_eval_binary_expression (const constexpr_ctx *ctx, tree t, && (null_member_pointer_value_p (lhs) || null_member_pointer_value_p (rhs))) r = constant_boolean_node (!is_code_eq, type); + else if (TREE_CODE (lhs) == PTRMEM_CST) + lhs = cplus_expand_constant (lhs); + else if (TREE_CODE (rhs) == PTRMEM_CST) + rhs = cplus_expand_constant (rhs); } if (r == NULL_TREE) diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-ptrmem6.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-ptrmem6.C new file mode 100644 index 0000000..ed18ab1 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-ptrmem6.C @@ -0,0 +1,13 @@ +// PR c++/71896 +// { dg-do compile { target c++11 } } + +struct Foo { + int x; +}; + +constexpr bool compare(int Foo::*t) { return t == &Foo::x; } + +constexpr bool b = compare(&Foo::x); + +#define SA(X) static_assert ((X),#X) +SA(b); |