Skip to content

[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 #162033

@ohno-fj

Description

@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:

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)
$

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions