===================================================================
@@ -255,3 +255,13 @@ fc4b (x)
{
}
void fc4b (_Atomic int); /* { dg-warning "follows non-prototype" } */
+
+/* Test cases involving C_MAYBE_CONST_EXPR work. */
+void
+func10 (_Atomic int *p)
+{
+ p[0 / 0] = 1; /* { dg-warning "division by zero" } */
+ p[0 / 0] += 1; /* { dg-warning "division by zero" } */
+ *p = 0 / 0; /* { dg-warning "division by zero" } */
+ *p += 0 / 0; /* { dg-warning "division by zero" } */
+}
===================================================================
@@ -11292,6 +11292,10 @@ build_atomic_assign (location_t loc, tree lhs, enu
with a loop. */
compound_stmt = c_begin_compound_stmt (false);
+ /* Fold the RHS if it hasn't already been folded. */
+ if (modifycode != NOP_EXPR)
+ rhs = c_fully_fold (rhs, false, NULL);
+
/* Remove the qualifiers for the rest of the expressions and create
the VAL temp variable to hold the RHS. */
nonatomic_lhs_type = build_qualified_type (lhs_type, TYPE_UNQUALIFIED);