Issue 162033
Summary [Flang][OpenMP] No error checking when specifying named common block in LASTPRIVATE clause of the PARALLEL DO construct and its member in FIRSTPRIVATE clause of the same construct
Labels flang:openmp
Assignees
Reporter ohno-fj
    ```
Version of flang : 22.0.0(48a6f2f85c8269d8326c185016801a4eb8d5dfd6)/AArch64
```

The attached program (`snf_err_omp_default_05_2.f90`) is incorrect.  
When specifying `named common block` in `LASTPRIVATE clause` of the `PARALLEL DO construct` and its member in `FIRSTPRIVATE clause` of the same construct, no error is detected during compilation.  
According to `OpenMP 6.0: 7.5 Data-Sharing Attribute Clauses`, this program is likely incorrect.  
Flang should detect errors in this program and output error message.  
`OpenMP 4.5` prohibits such description as seen in this program, but `OpenMP 6.0` does not appear to mention it.

The following are the test program, Flang, Gfortran and ifx compilation result.

snf_err_omp_default_05_2.f90:
```fortran
subroutine sub1()
  common /com/ j
  j=10
!$omp parallel do firstprivate(j) lastprivate(/com/)
  do i=1,10
     print*,j
     j=j+1
  enddo
!$omp end parallel do
end subroutine sub1

program main
  call sub1()
end program main
```

```
$ flang -fopenmp snf_err_omp_default_05_2.f90
$
```

```
$ gfortran -fopenmp snf_err_omp_default_05_2.f90
snf_err_omp_default_05_2.f90:4:47:

    4 | !$omp parallel do firstprivate(j) lastprivate(/com/)
      | 1
Error: Syntax error in OpenMP variable list at (1)
snf_err_omp_default_05_2.f90:9:21:

    9 | !$omp end parallel do
 |                     1
Error: Unexpected !$OMP END PARALLEL DO statement at (1)
$
```

```
$ ifx -qopenmp snf_err_omp_default_05_2.f90
snf_err_omp_default_05_2.f90(4): error #7657: When a named common block is declared in an OpenMP* PRIVATE, FIRSTPRIVATE, or LASTPRIVATE clause, none of its constituent variables may be declared in another OpenMP* scope attribute.   [J]
!$omp parallel do firstprivate(j) lastprivate(/com/)
-------------------------------^
compilation aborted for snf_err_omp_default_05_2.f90 (code 1)
$
```

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

Reply via email to