build_x_modify_expr sets it and it must not be reset
here. */
if (warning_suppressed_p (t, OPT_Wparentheses))
- suppress_warning (r, OPT_Wparentheses);
+ suppress_warning (STRIP_REFERENCE_REF (r), OPT_Wparentheses);
RETURN (r);
}
void
maybe_warn_unparenthesized_assignment (tree t, tsubst_flags_t complain)
{
- if (REFERENCE_REF_P (t))
- t = TREE_OPERAND (t, 0);
+ t = STRIP_REFERENCE_REF (t);
if ((complain & tf_warning)
&& warn_parentheses
{
/* This inhibits warnings in maybe_warn_unparenthesized_assignment
and c_common_truthvalue_conversion. */
- tree inner = REFERENCE_REF_P (expr) ? TREE_OPERAND (expr, 0) : *expr;
- suppress_warning (inner, OPT_Wparentheses);
+ suppress_warning (STRIP_REFERENCE_REF (*expr), OPT_Wparentheses);
}
if (TREE_CODE (expr) == OFFSET_REF
--- /dev/null
+// PR c++/112765
+
+struct A {
+ A& operator=(const A&);
+ operator bool() const;
+};
+
+template<class T>
+void f(A a1, A a2) {
+ if ((a2 = a1)) // { dg-bogus "parentheses" }
+ return;
+ bool b = (a2 = a1); // { dg-bogus "parentheses" }
+}
+
+template void f<int>(A, A);
+
+template<class T>
+void g(T a1, T a2) {
+ if ((a2 = a1)) // { dg-bogus "parentheses" }
+ return;
+ bool b = (a2 = a1); // { dg-bogus "parentheses" }
+}
+
+template void g<A>(A, A);