Commit dd5dda56 by Jason Merrill Committed by Jason Merrill

PR c++/71896 - constexpr pointer-to-member comparison.

	* constexpr.c (cxx_eval_binary_expression): Handle comparison
	between lowered and unlowered PTRMEM_CST.

From-SVN: r238562
parent 4683f47c
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.
......
......@@ -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)
......
// 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);
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment