Clang error: the statement for 'atomic capture' must be an expression statement of form 'v = ++x;', 'v = --x;', 'v = x++;', 'v = x--;', 'v = x binop= expr;', 'v = x = x binop expr' or 'v = x = expr binop x', where x and v are both lvalue expressions with scalar type (err_omp_atomic_capture_not_expression_statement)
Jump to navigation
Jump to search
Text | error: the statement for 'atomic capture' must be an expression statement of form 'v = ++x;', 'v = --x;', 'v = x++;', 'v = x--;', 'v = x binop= expr;', 'v = x = x binop expr' or 'v = x = expr binop x', where x and v are both lvalue expressions with scalar type (since 12.0) error: the statement for 'atomic capture' must be an expression statement of form 'v = ++x;', 'v = --x;', 'v = x++;', 'v = x--;', 'v = x binop= expr;', 'v = x = x binop expr' or 'v = x = expr binop x', where x and v are both l-value expressions with scalar type (until 11.1) |
---|---|
Type | Error |
Category | OpenMP Issue |
Internal Id | err_omp_atomic_capture_not_expression_statement |
Internal Message | the statement for 'atomic capture' must be an expression statement of form 'v = ++x;', 'v = --x;', 'v = x++;', 'v = x--;', 'v = x binop= expr;', 'v = x = x binop expr' or 'v = x = expr binop x', where x and v are both lvalue expressions with scalar type (since 12.0)the statement for 'atomic capture' must be an expression statement of form 'v = ++x;', 'v = --x;', 'v = x++;', 'v = x--;', 'v = x binop= expr;', 'v = x = x binop expr' or 'v = x = expr binop x', where x and v are both l-value expressions with scalar type (until 11.1)
|
Regular Expression | (?:error|fatal error)\: the statement for 'atomic capture' must be an expression statement of form 'v \= \+\+x;', 'v \= \-\-x;', 'v \= x\+\+;', 'v \= x\-\-;', 'v \= x binop\= expr;', 'v \= x \= x binop expr' or 'v \= x \= expr binop x', where x and v are both lvalue expressions with scalar type
|
First Commit | 2014-07-24 459dec0ca2a7 [OPENMP] Initial parsing and sema analysis for clause 'capture' in 'atomic' directive. |
Description
Example
Flags | -fopenmp -xc
|
|
---|---|---|
Source |
#include <omp.h>
int main() {
int x = 0, v = 0;
#pragma omp atomic capture
v = x; // Invalid atomic capture
return 0;
}
| |
Compiler Output |
<source>:5:9: error: the statement for 'atomic capture' must be an expression statement of form 'v = ++x;', 'v = --x;', 'v = x++;', 'v = x--;', 'v = x binop= expr;', 'v = x = x binop expr' or 'v = x = expr binop x', where x and v are both lvalue expressions with scalar type <source>:5:9: note: expected built-in binary or unary operator |
Clang Internals (17.0.6)
Git Commit Message
[OPENMP] Initial parsing and sema analysis for clause 'capture' in 'atomic' directive. llvm-svn: 213842
Used in Clang Sources
This section lists all occurrences of the diagnostic within the Clang's codebase. For each occurrence, an auto-extracted snipped from the source code is listed including key elements like control structures, functions, or classes. It should illustrate the conditions under which the diagnostic is activated.
clang/lib/Sema/SemaOpenMP.cpp (line 12772)
StmtResult Sema::ActOnOpenMPAtomicDirective(ArrayRef<OMPClause *> Clauses, Stmt *AStmt, SourceLocation StartLoc, SourceLocation EndLoc) {
// ...
// OpenMP [2.12.6, atomic Construct]
// In the next expressions:
// * x and v (as applicable) are both l-value expressions with scalar type.
// * During the execution of an atomic region, multiple syntactic
// occurrences of x must designate the same storage location.
// * Neither of v and expr (as applicable) may access the storage location
// designated by x.
// * Neither of x and expr (as applicable) may access the storage location
// designated by v.
// * expr is an expression with scalar type.
// * binop is one of +, *, -, /, &, ^, |, <<, or >>.
// * binop, binop=, ++, 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.
// * For forms that allow multiple occurrences of x, the number of times
// that x is evaluated is unspecified.
if (AtomicKind == OMPC_read) {
// ...
} else if (AtomicKind == OMPC_write) {
// ...
} else if (AtomicKind == OMPC_update || AtomicKind == OMPC_unknown) {
// ...
} else if (AtomicKind == OMPC_capture) {
// ...
if (const auto *AtomicBody = dyn_cast<Expr>(Body)) {
// ...
if (AtomicBinOp && AtomicBinOp->getOpcode() == BO_Assign) {
// ...
if (Checker.checkStatement(Body, diag::err_omp_atomic_capture_not_expression_statement, diag::note_omp_atomic_update))
clang/lib/Sema/SemaOpenMP.cpp (line 12790)
StmtResult Sema::ActOnOpenMPAtomicDirective(ArrayRef<OMPClause *> Clauses, Stmt *AStmt, SourceLocation StartLoc, SourceLocation EndLoc) {
// ...
// OpenMP [2.12.6, atomic Construct]
// In the next expressions:
// * x and v (as applicable) are both l-value expressions with scalar type.
// * During the execution of an atomic region, multiple syntactic
// occurrences of x must designate the same storage location.
// * Neither of v and expr (as applicable) may access the storage location
// designated by x.
// * Neither of x and expr (as applicable) may access the storage location
// designated by v.
// * expr is an expression with scalar type.
// * binop is one of +, *, -, /, &, ^, |, <<, or >>.
// * binop, binop=, ++, 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.
// * For forms that allow multiple occurrences of x, the number of times
// that x is evaluated is unspecified.
if (AtomicKind == OMPC_read) {
// ...
} else if (AtomicKind == OMPC_write) {
// ...
} else if (AtomicKind == OMPC_update || AtomicKind == OMPC_unknown) {
// ...
} else if (AtomicKind == OMPC_capture) {
// ...
if (const auto *AtomicBody = dyn_cast<Expr>(Body)) {
// ...
if (ErrorFound != NoError) {
Diag(ErrorLoc, diag::err_omp_atomic_capture_not_expression_statement) << ErrorRange;
Triggered in Clang Tests
This section lists all internal Clang test cases that trigger the diagnostic.
clang/test/OpenMP/atomic_messages.c
- clang/test/OpenMP/atomic_messages.c:218:3: error: the statement for 'atomic capture' must be an expression statement of form 'v = ++x;', 'v = --x;', 'v = x++;', 'v = x--;', 'v = x binop= expr;', 'v = x = x binop expr' or 'v = x = expr binop x', where x and v are both lvalue expressions with scalar type
- clang/test/OpenMP/atomic_messages.c:222:7: error: the statement for 'atomic capture' must be an expression statement of form 'v = ++x;', 'v = --x;', 'v = x++;', 'v = x--;', 'v = x binop= expr;', 'v = x = x binop expr' or 'v = x = expr binop x', where x and v are both lvalue expressions with scalar type
- clang/test/OpenMP/atomic_messages.c:226:9: error: the statement for 'atomic capture' must be an expression statement of form 'v = ++x;', 'v = --x;', 'v = x++;', 'v = x--;', 'v = x binop= expr;', 'v = x = x binop expr' or 'v = x = expr binop x', where x and v are both lvalue expressions with scalar type
- clang/test/OpenMP/atomic_messages.c:230:13: error: the statement for 'atomic capture' must be an expression statement of form 'v = ++x;', 'v = --x;', 'v = x++;', 'v = x--;', 'v = x binop= expr;', 'v = x = x binop expr' or 'v = x = expr binop x', where x and v are both lvalue expressions with scalar type
- clang/test/OpenMP/atomic_messages.c:234:16: error: the statement for 'atomic capture' must be an expression statement of form 'v = ++x;', 'v = --x;', 'v = x++;', 'v = x--;', 'v = x binop= expr;', 'v = x = x binop expr' or 'v = x = expr binop x', where x and v are both lvalue expressions with scalar type
- clang/test/OpenMP/atomic_messages.c:238:9: error: the statement for 'atomic capture' must be an expression statement of form 'v = ++x;', 'v = --x;', 'v = x++;', 'v = x--;', 'v = x binop= expr;', 'v = x = x binop expr' or 'v = x = expr binop x', where x and v are both lvalue expressions with scalar type
- clang/test/OpenMP/atomic_messages.c:242:9: error: the statement for 'atomic capture' must be an expression statement of form 'v = ++x;', 'v = --x;', 'v = x++;', 'v = x--;', 'v = x binop= expr;', 'v = x = x binop expr' or 'v = x = expr binop x', where x and v are both lvalue expressions with scalar type
- clang/test/OpenMP/atomic_messages.c:264:20: error: the statement for 'atomic capture' must be an expression statement of form 'v = ++x;', 'v = --x;', 'v = x++;', 'v = x--;', 'v = x binop= expr;', 'v = x = x binop expr' or 'v = x = expr binop x', where x and v are both lvalue expressions with scalar type
- clang/test/OpenMP/atomic_messages.c:268:13: error: the statement for 'atomic capture' must be an expression statement of form 'v = ++x;', 'v = --x;', 'v = x++;', 'v = x--;', 'v = x binop= expr;', 'v = x = x binop expr' or 'v = x = expr binop x', where x and v are both lvalue expressions with scalar type
- clang/test/OpenMP/atomic_messages.c:272:13: error: the statement for 'atomic capture' must be an expression statement of form 'v = ++x;', 'v = --x;', 'v = x++;', 'v = x--;', 'v = x binop= expr;', 'v = x = x binop expr' or 'v = x = expr binop x', where x and v are both lvalue expressions with scalar type