The syntax of the atomic construct is:

#pragma omp atomic [clause[[,] clause] ... ] new-line

statement

where statement is a statement with one of the following forms:

- If atomic-clause is read then statement is read-expr-stmt, a read expression statement that has the
following form:

v = x; - If atomic-clause is write then statement is write-expr-stmt, a write expression statement that has the
following form:

x = expr; - If atomic-clause is update then statement can be update-expr-stmt, an update expression statement that
has one of the following forms:

x++;

x--;

++x;

--x;

x binop= expr;

x = x binop expr;

x = expr binop x; - If the compare clause is present then either statement is:
- cond-expr-stmt, a conditional expression statement that has one of the following forms:

x = expr ordop x ? expr : x;

x = x ordop expr ? expr : x;

x = x == e ? d : x; - or cond-update-stmt, a conditional update statement that has one of the following forms:

if(expr ordop x) { x = expr; }

if(x ordop expr) { x = expr; }

if(x == e) { x = d; }

- cond-expr-stmt, a conditional expression statement that has one of the following forms:
- If the capture clause is present, statement can have one of the following forms:

v = expr-stmt

{ v = x; expr-stmt }

{ expr-stmt v = x; }where expr-stmt is either write-expr-stmt, update-expr-stmt or cond-expr-stmt.

- If both the compare and capture clauses are present then the following forms are also
valid:

{ v = x; cond-update-stmt }

{ cond-update-stmt v = x; }

if(x == e) { x = d; } else { v = x; }

{ r = x == e; if(r) { x = d; } }

{ r = x == e; if(r) { x = d; } else { v = x; } }

In the preceding expressions:

- x, r (result), and v (as applicable) are lvalue expressions with scalar type.
- e (expected) is an expression with scalar type, in forms where e is assigned it must be an lvalue.
- d (desired) is an expression with scalar type.
- r must be of integral type.
- During the execution of an atomic region, multiple syntactic occurrences of x must designate the same storage location.
- None of v, x, r, d and expr (as applicable) may access the storage location designated by any other in the list.
- e and v may refer to, or access, the same storage location.
- expr is an expression with scalar type.
- The order operation, ordop, is one of <, or >.
- binop is one of +, *, -, /, &, ^, |, <<, or >>.
- binop, binop=, ordop, ==, ++, and -- are not overloaded operators.
- The expression x binop expr must be numerically equivalent to x binop (expr). This requirement is satisfied if the operators in expr have precedence greater than binop, or by using parentheses around expr or subexpressions of expr.
- The expression expr binop x must be numerically equivalent to (expr) binop x. This requirement is satisfied if the operators in expr have precedence equal to or greater than binop, or by using parentheses around expr or subexpressions of expr.
- == comparisons are performed by comparing the bits that comprise each object as with memcmp.
- For forms that allow multiple occurrences of x, the number of times that x is evaluated is unspecified.
- hint-expression is a constant integer expression that evaluates to a valid synchronization hint.