&& same_type_p (arg2_type, arg3_type))
{
result_type = arg2_type;
- arg2 = mark_lvalue_use (arg2);
- arg3 = mark_lvalue_use (arg3);
goto valid_operands;
}
a volatile-qualified type is deprecated unless the assignment
is either a discarded-value expression or appears in an
unevaluated context." */
- if (read_p
- && !cp_unevaluated_operand
+ if (!cp_unevaluated_operand
&& (TREE_THIS_VOLATILE (lhs)
|| CP_TYPE_VOLATILE_P (TREE_TYPE (lhs)))
&& !TREE_THIS_VOLATILE (expr))
{
- warning_at (location_of (expr), OPT_Wvolatile,
- "using value of simple assignment with %<volatile%>-"
- "qualified left operand is deprecated");
- /* Make sure not to warn about this assignment again. */
- TREE_THIS_VOLATILE (expr) = true;
+ if (warning_at (location_of (expr), OPT_Wvolatile,
+ "using value of simple assignment with "
+ "%<volatile%>-qualified left operand is "
+ "deprecated"))
+ /* Make sure not to warn about this assignment again. */
+ TREE_THIS_VOLATILE (expr) = true;
}
break;
}
--- /dev/null
+// PR c++/98947
+// { dg-do compile }
+
+volatile int x, y, z;
+
+void
+f (bool b)
+{
+ (b ? x : y) = 1;
+ (b ? x : y) += 1; // { dg-warning "compound assignment" "" { target c++20 } }
+ z = (b ? x : y) = 1; // { dg-warning "using value of simple assignment" "" { target c++20 } }
+ ((z = 2) ? x : y) = 1; // { dg-warning "using value of simple assignment" "" { target c++20 } }
+ (b ? (x = 2) : y) = 1; // { dg-warning "using value of simple assignment" "" { target c++20 } }
+ (b ? x : (y = 5)) = 1; // { dg-warning "using value of simple assignment" "" { target c++20 } }
+}