[flang-commits] [flang] [Flang][OpenMP] DEFAULT(NONE) error checking on implicit references (PR #182214)
Leandro Lupori via flang-commits
flang-commits at lists.llvm.org
Thu Mar 5 07:00:51 PST 2026
luporl wrote:
@sscalpone In this case it seems to me that the test is incorrect.
I agree that `i1` is predetermined as lastprivate for the `parallel do simd` construct, according to OpenMP 6.0 spec.
However, `i1` data-sharing attribute is undefined for the `task` construct, and lastprivate causes an implicit reference to `i1` in the `task` construct, according to section 7.1.1:
Specifying a variable in a copyprivate clause or a data-sharing attribute clause other than the
private clause on a nested construct causes an implicit reference to the variable in the enclosing
construct.
Gfortran seems to agree with this interpretation and emits an error:
```
ftest.f90:4:42:
4 | !$omp parallel do simd
| ^
Error: 'i1' not specified in enclosing 'task'
ftest.f90:3:44:
3 | !$omp task default(none)
| ^
note: enclosing 'task'
```
Ifx doesn't complain about this, but it also limits the scope of predetermined variables to the affected construct, as in the example below.
```f90
implicit none
integer :: i = 1
!$omp parallel
!$omp task
print *, "task i (before parallel do):", i
i = 2
!$omp parallel do
do i = 1, 5
end do
print *, "task i (after parallel do):", i
!$omp end task
!$omp end parallel
print *, "program i:", i
end
```
The output is:
```
task i (before parallel do): 1
task i (before parallel do): 2
task i (after parallel do): 2
task i (after parallel do): 2
program i: 2
```
`i` is shared in the first `parallel` construct and in `task`, before `parallel do`.
I'm not an OpenMP expert either, so it would be good to hear other opinions on this.
https://github.com/llvm/llvm-project/pull/182214
More information about the flang-commits
mailing list