{
if (type_dependent_expression_p (op1)
|| type_dependent_expression_p (op2))
- return build_min_nt_loc (loc, COMPOUND_EXPR, op1, op2);
+ {
+ result = build_min_nt_loc (loc, COMPOUND_EXPR, op1, op2);
+ maybe_save_operator_binding (result);
+ return result;
+ }
op1 = build_non_dependent_expr (op1);
op2 = build_non_dependent_expr (op2);
}
tree orig_lhs = lhs;
tree orig_rhs = rhs;
tree overload = NULL_TREE;
- tree op = build_nt (modifycode, NULL_TREE, NULL_TREE);
if (lhs == error_mark_node || rhs == error_mark_node)
return cp_expr (error_mark_node, loc);
if (modifycode == NOP_EXPR
|| type_dependent_expression_p (lhs)
|| type_dependent_expression_p (rhs))
- return build_min_nt_loc (loc, MODOP_EXPR, lhs,
- build_min_nt_loc (loc, modifycode, NULL_TREE,
- NULL_TREE), rhs);
+ {
+ tree op = build_min_nt_loc (loc, modifycode, NULL_TREE, NULL_TREE);
+ tree rval = build_min_nt_loc (loc, MODOP_EXPR, lhs, op, rhs);
+ maybe_save_operator_binding (rval);
+ return rval;
+ }
lhs = build_non_dependent_expr (lhs);
rhs = build_non_dependent_expr (rhs);
if (modifycode != NOP_EXPR)
{
+ tree op = build_nt (modifycode, NULL_TREE, NULL_TREE);
tree rval = build_new_op (loc, MODIFY_EXPR, LOOKUP_NORMAL,
lhs, rhs, op, &overload, complain);
if (rval)
--- /dev/null
+// PR c++/51577
+
+template <class T> void f (T x) {
+ +x; // { dg-error "no match" }
+ -x; // { dg-error "no match" }
+ *x; // { dg-error "no match" }
+ ~x; // { dg-error "no match" }
+ &x;
+ !x; // { dg-error "no match" }
+ ++x; // { dg-error "no match" }
+ --x; // { dg-error "no match" }
+ x++; // { dg-error "declared for postfix" }
+ x--; // { dg-error "declared for postfix" }
+
+ x->*x; // { dg-error "no match" }
+ x / x; // { dg-error "no match" }
+ x * x; // { dg-error "no match" }
+ x + x; // { dg-error "no match" }
+ x - x; // { dg-error "no match" }
+ x % x; // { dg-error "no match" }
+ x & x; // { dg-error "no match" }
+ x | x; // { dg-error "no match" }
+ x ^ x; // { dg-error "no match" }
+ x << x; // { dg-error "no match" }
+ x >> x; // { dg-error "no match" }
+ x && x; // { dg-error "no match" }
+ x || x; // { dg-error "no match" }
+ x, x;
+
+ x == x; // { dg-error "no match" }
+ x != x; // { dg-error "no match" }
+ x < x; // { dg-error "no match" }
+ x > x; // { dg-error "no match" }
+ x <= x; // { dg-error "no match" }
+ x >= x; // { dg-error "no match" }
+#if __cplusplus > 201703L
+ x <=> x; // { dg-error "no match" "" { target c++20 } }
+#endif
+
+ x += x; // { dg-error "no match" }
+ x -= x; // { dg-error "no match" }
+ x *= x; // { dg-error "no match" }
+ x /= x; // { dg-error "no match" }
+ x %= x; // { dg-error "no match" }
+ x |= x; // { dg-error "no match" }
+ x ^= x; // { dg-error "no match" }
+ x <<= x; // { dg-error "no match" }
+ x >>= x; // { dg-error "no match" }
+}
+
+namespace N { struct A { }; }
+
+void operator+(N::A);
+void operator-(N::A);
+void operator*(N::A);
+void operator~(N::A);
+#if __cplusplus >= 201103L
+void operator&(N::A) = delete;
+#else
+void operator&(N::A);
+#endif
+void operator!(N::A);
+void operator++(N::A);
+void operator--(N::A);
+void operator++(N::A, int);
+void operator--(N::A, int);
+
+void operator->*(N::A, N::A);
+void operator/(N::A, N::A);
+void operator*(N::A, N::A);
+void operator+(N::A, N::A);
+void operator-(N::A, N::A);
+void operator%(N::A, N::A);
+void operator&(N::A, N::A);
+void operator|(N::A, N::A);
+void operator^(N::A, N::A);
+void operator<<(N::A, N::A);
+void operator>>(N::A, N::A);
+void operator&&(N::A, N::A);
+void operator||(N::A, N::A);
+#if __cplusplus >= 201103L
+void operator,(N::A, N::A) = delete;
+#else
+void operator,(N::A, N::A);
+#endif
+
+void operator==(N::A, N::A);
+void operator!=(N::A, N::A);
+void operator<(N::A, N::A);
+void operator>(N::A, N::A);
+void operator<=(N::A, N::A);
+void operator>=(N::A, N::A);
+#if __cplusplus > 201703L
+void operator<=>(N::A, N::A);
+#endif
+
+void operator+=(N::A, N::A);
+void operator-=(N::A, N::A);
+void operator*=(N::A, N::A);
+void operator/=(N::A, N::A);
+void operator%=(N::A, N::A);
+void operator|=(N::A, N::A);
+void operator^=(N::A, N::A);
+void operator<<=(N::A, N::A);
+void operator>>=(N::A, N::A);
+
+int main() {
+ f(N::A());
+}