Files
clang-p2996/flang/test/Semantics/OpenMP/private03.f90
Tom Eccles c734d77b99 [flang][semantics][OpenMP] no privatisation of stmt functions (#106550)
OpenMP prohibits privatisation of variables that appear in expressions
for statement functions.

This is a re-working of an old patch https://reviews.llvm.org/D93213 by
@praveen-g-ctt.

The old patch couldn't be landed because of ordering concerns. Statement
functions are rewritten during parse tree rewriting, but this was done
after resolve-directives and so some array expressions were incorrectly
identified as statement functions. For this reason **I have opted to
re-order the semantics driver so that resolve-directives is run after
parse tree rewriting**.

Closes #54677

---------

Co-authored-by: Praveen <praveen@compilertree.com>
2024-10-04 10:46:31 +01:00

40 lines
1011 B
Fortran

! RUN: %python %S/../test_errors.py %s %flang -fopenmp
! OpenMP Version 4.5
! Variables that appear in expressions for statement function definitions
! may not appear in private, firstprivate or lastprivate clauses.
subroutine stmt_function(temp)
integer :: i, p, q, r
real :: c, f, s, v, t(10)
real, intent(in) :: temp
c(temp) = p * (temp - q) / r
f(temp) = q + (temp * r/p)
v(temp) = c(temp) + f(temp)/2 - s
p = 5
q = 32
r = 9
!ERROR: Variable 'p' in statement function expression cannot be in a PRIVATE clause
!$omp parallel private(p)
s = c(temp)
!$omp end parallel
!ERROR: Variable 's' in statement function expression cannot be in a FIRSTPRIVATE clause
!$omp parallel firstprivate(s)
s = s + f(temp)
!$omp end parallel
!ERROR: Variable 's' in statement function expression cannot be in a LASTPRIVATE clause
!$omp parallel do lastprivate(s, t)
do i = 1, 10
t(i) = v(temp) + i - s
end do
!$omp end parallel do
print *, t
end subroutine stmt_function