[Flang][OpenMP] Incorrect rejection of Fortran BLOCK construct inside WORKSHARE structured block
- Dominant language
- LLVM
- Stars
- 40.5k
- Forks
- 18.7k
- PR merge metrics
- PR metrics pending
Description
Flang incorrectly rejects a Fortran BLOCK construct when it appears inside an OpenMP WORKSHARE region, even when the contents of the BLOCK consist solely of statements that are valid within a WORKSHARE construct.
[WORKSHARE CONSTRUCT](https://www.openmp.org/spec-html/5.0/openmpsu39.html#x61-1170002.8.3)
Other compilers (gfortran 15.2, ifort 2021, ifx 2023) all accept this code.
```fortran
subroutine test(a, b)
!$OMP workshare
block
a = b
end block
!$OMP end workshare
end subroutine
```
Compile with:``` flang -fopenmp -fopenmp-version=51 -c```
### Observed Behavior
```
error: The structured block in a WORKSHARE construct may consist of only
SCALAR or ARRAY assignments, FORALL or WHERE statements, FORALL, WHERE,
ATOMIC, CRITICAL or PARALLEL constructs
```
### Expected Behaviour
```
The code should compile successfully.
The BLOCK construct is a Fortran scoping construct (F2008) and does not introduce new executable semantics. The only executable statement within the BLOCK is a scalar assignment [a = b] , which is explicitly permitted inside a WORKSHARE construct.
```
Contributor guide
Assessment
This issue has not been assessed yet.