llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
28.61k stars 11.83k forks source link

[Flang][OpenMP] Unexpected warning emitted for a FORALL construct #63828

Open rofirrim opened 1 year ago

rofirrim commented 1 year ago

When compiling the following testcase with OpenMP enabled

! t.f90
subroutine p(n, k)
 implicit none
 integer :: i
 integer :: j
 integer :: n
 integer :: k(10, 10)

!$omp task private(i, j) shared(k)
 forall(i=1:10, j=1:10) k(i, j) = 0
!$omp end task
end subroutine p

the following diagnostics are emitted

$ flang-new -c t.f90  -fopenmp
./t.f90:10:25: warning: FORALL index variable 'i' not used on left-hand side of assignment
   forall(i=1:10, j=1:10) k(i, j) = 0
                          ^^^^^^^^^^^
./t.f90:10:25: warning: FORALL index variable 'j' not used on left-hand side of assignment
   forall(i=1:10, j=1:10) k(i, j) = 0
                          ^^^^^^^^^^^

but the variables are indeed used.

The diagnostic is not emitted if OpenMP is not enabled.

llvmbot commented 1 year ago

@llvm/issue-subscribers-openmp

llvmbot commented 1 year ago

@llvm/issue-subscribers-flang-frontend