+2016-02-04 Patrick Palka <ppalka@gcc.gnu.org>
+
+ * constexpr.c (cxx_eval_binary_expression): Fold equality
+ comparisons involving PTRMEM_CSTs.
+
2016-02-04 Jakub Jelinek <jakub@redhat.com>
* class.c (find_flexarrays): Don't declare dom variable.
bool /*lval*/,
bool *non_constant_p, bool *overflow_p)
{
- tree r;
+ tree r = NULL_TREE;
tree orig_lhs = TREE_OPERAND (t, 0);
tree orig_rhs = TREE_OPERAND (t, 1);
tree lhs, rhs;
location_t loc = EXPR_LOCATION (t);
enum tree_code code = TREE_CODE (t);
tree type = TREE_TYPE (t);
- r = fold_binary_loc (loc, code, type, lhs, rhs);
+
+ if (code == EQ_EXPR || code == NE_EXPR)
+ {
+ bool is_code_eq = (code == EQ_EXPR);
+
+ if (TREE_CODE (lhs) == PTRMEM_CST
+ && TREE_CODE (rhs) == PTRMEM_CST)
+ r = constant_boolean_node (cp_tree_equal (lhs, rhs) == is_code_eq,
+ type);
+ else if ((TREE_CODE (lhs) == PTRMEM_CST
+ || TREE_CODE (rhs) == PTRMEM_CST)
+ && (null_member_pointer_value_p (lhs)
+ || null_member_pointer_value_p (rhs)))
+ r = constant_boolean_node (!is_code_eq, type);
+ }
+
+ if (r == NULL_TREE)
+ r = fold_binary_loc (loc, code, type, lhs, rhs);
+
if (r == NULL_TREE)
{
if (lhs == orig_lhs && rhs == orig_rhs)
+2016-02-04 Patrick Palka <ppalka@gcc.gnu.org>
+
+ * g++.dg/cpp0x/constexpr-ptrmem5.C: New test.
+
2016-02-04 Jakub Jelinek <jakub@redhat.com>
PR c/69669
2016-02-03 Patrick Palka <ppalka@gcc.gnu.org>
PR c++/69056
- g++.dg/cpp0x/pr69056.C: New test.
+ * g++.dg/cpp0x/pr69056.C: New test.
2016-02-03 Vladimir Makarov <vmakarov@redhat.com>
Alexandre Oliva <aoliva@redhat.com>
--- /dev/null
+// { 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::a));
+ SA (&X::a != &X::b);
+ SA (!(&X::a == &X::b));
+ SA ((!&X::b) == 0);
+ SA (!(&X::b == 0));
+}