Issue 179250
Summary Flang OpenMP: Incorrect diagnostic for closely nested worksharing regions
Labels flang
Assignees
Reporter blazie2004
    ### Problem 
Flang incorrectly rejects valid OpenMP code containing nested PARALLEL SECTIONS and PARALLEL DO constructs with the error: 
```
error: A worksharing region may not be closely nested inside a worksharing, 
explicit task, taskloop, critical, ordered, atomic, or master region
```
### Cause
PARALLEL SECTIONS is a combined construct that creates its own parallel region. Flang incorrectly treats it as a simple worksharing construct when checking nesting rules.
Per OpenMP 5.0 Section 2.13.3, PARALLEL SECTIONS is equivalent to:


```
!$OMP PARALLEL
!$OMP SECTIONS
  ...
!$OMP END SECTIONS
!$OMP END PARALLEL
```
Since it includes a PARALLEL region, it should be allowed to nest inside other parallel regions.


### Testcase
```
program omp_small
  implicit none
  integer :: i, j

!$omp parallel sections
!$omp section
!$omp parallel sections
!$omp section
  i = 1
!$omp end parallel sections
!$omp section
!$omp parallel do
  do i = 1, 4
    j = i
  end do
!$omp end parallel do
!$omp end parallel sections

end program omp_small
```

### Expected Behavior
Code compiles perfectly 

### Current Behavior
```
error: A worksharing region may not be closely nested inside a worksharing, 
explicit task, taskloop, critical, ordered, atomic, or master region
  !$OMP PARALLEL SECTIONS

```

I will provide a fix that addresses this issue by raising a pr , if analysis looks correct . 


_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to