Skip to content

[Flang][OpenMP] Missing semantic check: LINEAR clause variable in statement function expression #199660

@blazie2004

Description

@blazie2004

Description:

Flang does not diagnose when a variable appearing in a statement function expression is specified in a LINEAR clause.

The Cray Fortran compiler (CCE) correctly diagnoses this:

ftn-1760: "X" is referenced in a statement function expression, so it must not be specified in the LINEAR clause.

Reproducer:

subroutine test()
  integer :: pi, r, f, x

  f(r) = pi * r + x

  !$omp parallel do linear(x)
  do r = 1, 10
    pi = f(r)
  end do
  !$omp end parallel do
end subroutine

Expected Behavior:

error: Variable 'x' in statement function expression cannot be in a LINEAR clause

Actual Behavior:

No diagnostic is emitted; compilation succeeds.

Specification References:

  • OpenMP 4.5, Section 2.15.3.7:

    A list item that appears in a linear clause is subject to the private clause semantics described in Section 2.15.3.3.

  • OpenMP 4.5, Section 2.15.3.3:

    Variables that appear in namelist statements, in variable format expressions, and in expressions for statement function definitions, may not appear in a private clause.

  • OpenMP 5.3, Section 5.3:

    Variables that appear in namelist statements, in variable format expressions, and in expressions for statement function definitions, must not be privatized.

Additional Notes:

Other compilers tested, including gfortran, flang, and ifort/ifx, currently accept the code without emitting a diagnostic, while CCE correctly rejects it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions