llvm-project/flang/test/Semantics/omp-threadprivate04.f90
Peixin-Qiao 8eb74626fa [flang][OpenMP] Add some semantic checks for threadprivate and declare target directives
This supports the following checks for THREADPRIVATE Directive:
```
[5.1] 2.21.2 THREADPRIVATE Directive
A threadprivate variable must not appear in any clause except the
copyin, copyprivate, schedule, num_threads, thread_limit, and if clauses.
```

This supports the following checks for DECLARE TARGET Directive:
```
[5.1] 2.14.7 Declare Target Directive
A threadprivate variable cannot appear in the directive.
```

Besides, procedure name and the entity with PARAMETER attribute cannot
be in the threadprivate directive. The main program name and module name
cannot be in the threadprivate directive and declare target directive.
There is no clear description or restriction about the entity with
PARAMETER attribute in OpenMP 5.1 Specification, and a warning is given.

Reviewed By: kiranchandramohan, shraiysh, NimishMishra

Differential Revision: https://reviews.llvm.org/D114941
2022-01-06 20:00:16 +08:00

49 lines
1.2 KiB
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
integer :: i, N = 10
integer, save :: x
common /blk/ y
!$omp threadprivate(x, /blk/)
!$omp parallel num_threads(x)
!$omp end parallel
!$omp single copyprivate(x, /blk/)
!$omp end single
!$omp do schedule(static, x)
do i = 1, N
y = x
end do
!$omp end do
!$omp parallel copyin(x, /blk/)
!$omp end parallel
!$omp parallel if(x > 1)
!$omp end parallel
!$omp teams thread_limit(x)
!$omp end teams
!ERROR: A THREADPRIVATE variable cannot be in PRIVATE clause
!ERROR: A THREADPRIVATE variable cannot be in PRIVATE clause
!$omp parallel private(x, /blk/)
!$omp end parallel
!ERROR: A THREADPRIVATE variable cannot be in FIRSTPRIVATE clause
!ERROR: A THREADPRIVATE variable cannot be in FIRSTPRIVATE clause
!$omp parallel firstprivate(x, /blk/)
!$omp end parallel
!ERROR: A THREADPRIVATE variable cannot be in SHARED clause
!ERROR: A THREADPRIVATE variable cannot be in SHARED clause
!$omp parallel shared(x, /blk/)
!$omp end parallel
end