Files
clang-p2996/flang/test/Semantics/OpenMP/threadprivate06.f90
Leandro Lupori 499d41cef2 [flang][OpenMP] Fix threadprivate common blocks (#68739)
Using a threadprivate common block within a nested scope resulted
in compilation errors.

This happened because common block names were being first resolved
to those in the parent scope. Because of this, in a nested scope,
an inner threadprivate directive would be applied to the outter
common block. This caused a 'common_block appears in more than one
data-sharing clause' error.

Also, when a copyin clause in a parallel region tried to use the
common block, getting the inner version of it, their objects would
be missing the threadprivate attribute, causing a 'Non-THREADPRIVATE
object in COPYIN clause' error.

Fixes https://github.com/llvm/llvm-project/issues/61200
2023-10-16 09:12:53 -03:00

31 lines
570 B
Fortran

! RUN: %python %S/../test_errors.py %s %flang_fc1 -fopenmp
! OpenMP Version 5.1
! Check OpenMP construct validity for the following directives:
! 2.21.2 Threadprivate Directive
program main
call sub1()
print *, 'pass'
end program main
subroutine sub1()
common /c/ a
!$omp threadprivate(/c/)
integer :: a
a = 100
call sub2()
if (a .ne. 101) print *, 'err'
contains
subroutine sub2()
common /c/ a
!$omp threadprivate(/c/)
integer :: a
!$omp parallel copyin(/c/)
a = a + 1
!$omp end parallel
end subroutine
end subroutine