The parser will accept a wide variety of illegal attempts at forming an ATOMIC construct, leaving it to the semantic analysis to diagnose any issues. This consolidates the analysis into one place and allows us to produce more informative diagnostics. The parser's outcome will be parser::OpenMPAtomicConstruct object holding the directive, parser::Body, and an optional end-directive. The prior variety of OmpAtomicXyz classes, as well as OmpAtomicClause have been removed. READ, WRITE, etc. are now proper clauses. The semantic analysis consistently operates on "evaluation" representations, mainly evaluate::Expr (as SomeExpr) and evaluate::Assignment. The results of the semantic analysis are stored in a mutable member of the OpenMPAtomicConstruct node. This follows a precedent of having `typedExpr` member in parser::Expr, for example. This allows the lowering code to avoid duplicated handling of AST nodes. Using a BLOCK construct containing multiple statements for an ATOMIC construct that requires multiple statements is now allowed. In fact, any nesting of such BLOCK constructs is allowed. This implementation will parse, and perform semantic checks for both conditional-update and conditional-update-capture, although no MLIR will be generated for those. Instead, a TODO error will be issues prior to lowering. The allowed forms of the ATOMIC construct were based on the OpenMP 6.0 spec.
30 lines
1.1 KiB
Fortran
30 lines
1.1 KiB
Fortran
! REQUIRES: openmp_runtime
|
|
|
|
! RUN: %python %S/../test_errors.py %s %flang %openmp_flags -fopenmp-version=50
|
|
|
|
! This tests the various semantics related to the clauses of various OpenMP atomic constructs
|
|
|
|
program OmpAtomic
|
|
use omp_lib
|
|
integer :: g, x
|
|
|
|
!ERROR: At most one clause from the 'memory-order' group is allowed on ATOMIC construct
|
|
!$omp atomic relaxed, seq_cst
|
|
x = x + 1
|
|
!ERROR: At most one clause from the 'memory-order' group is allowed on ATOMIC construct
|
|
!$omp atomic read seq_cst, relaxed
|
|
x = g
|
|
!ERROR: At most one clause from the 'memory-order' group is allowed on ATOMIC construct
|
|
!$omp atomic write relaxed, release
|
|
x = 2 * 4
|
|
!ERROR: At most one clause from the 'memory-order' group is allowed on ATOMIC construct
|
|
!$omp atomic update release, seq_cst
|
|
!ERROR: The atomic variable x should appear as an argument in the update operation
|
|
x = 10
|
|
!ERROR: At most one clause from the 'memory-order' group is allowed on ATOMIC construct
|
|
!$omp atomic capture release, seq_cst
|
|
x = g
|
|
g = x * 10
|
|
!$omp end atomic
|
|
end program OmpAtomic
|