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
153 lines
5.7 KiB
Fortran
153 lines
5.7 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.14.7 Declare Target Directive
|
|
|
|
program declare_target02
|
|
integer :: arr1(10), arr1_to(10), arr1_link(10)
|
|
common /blk1/ a1, a1_to, a1_link
|
|
real, save :: eq_a, eq_b, eq_c, eq_d
|
|
|
|
|
|
!$omp declare target (arr1)
|
|
|
|
!$omp declare target (blk1)
|
|
|
|
!ERROR: A variable in a DECLARE TARGET directive cannot be an element of a common block
|
|
!$omp declare target (a1)
|
|
|
|
!$omp declare target to (arr1_to)
|
|
|
|
!$omp declare target to (blk1_to)
|
|
|
|
!ERROR: A variable in a DECLARE TARGET directive cannot be an element of a common block
|
|
!$omp declare target to (a1_to)
|
|
|
|
!$omp declare target link (arr1_link)
|
|
|
|
!$omp declare target link (blk1_link)
|
|
|
|
!ERROR: A variable in a DECLARE TARGET directive cannot be an element of a common block
|
|
!$omp declare target link (a1_link)
|
|
|
|
equivalence(eq_a, eq_b)
|
|
!ERROR: A variable in a DECLARE TARGET directive cannot appear in an EQUIVALENCE statement
|
|
!$omp declare target (eq_a)
|
|
|
|
!ERROR: A variable in a DECLARE TARGET directive cannot appear in an EQUIVALENCE statement
|
|
!$omp declare target to (eq_a)
|
|
|
|
!ERROR: A variable in a DECLARE TARGET directive cannot appear in an EQUIVALENCE statement
|
|
!$omp declare target link (eq_b)
|
|
|
|
!ERROR: A variable in a DECLARE TARGET directive cannot appear in an EQUIVALENCE statement
|
|
!$omp declare target (eq_c)
|
|
|
|
!ERROR: A variable in a DECLARE TARGET directive cannot appear in an EQUIVALENCE statement
|
|
!$omp declare target to (eq_c)
|
|
|
|
!ERROR: A variable in a DECLARE TARGET directive cannot appear in an EQUIVALENCE statement
|
|
!$omp declare target link (eq_d)
|
|
equivalence(eq_c, eq_d)
|
|
|
|
contains
|
|
subroutine func()
|
|
integer :: arr2(10), arr2_to(10), arr2_link(10)
|
|
integer, save :: arr3(10), arr3_to(10), arr3_link(10)
|
|
common /blk2/ a2, a2_to, a2_link
|
|
common /blk3/ a3, a3_to, a3_link
|
|
save /blk3/
|
|
|
|
!ERROR: A variable that appears in a DECLARE TARGET directive must be declared in the scope of a module or have the SAVE attribute, either explicitly or implicitly
|
|
!$omp declare target (arr2)
|
|
|
|
!$omp declare target (arr3)
|
|
|
|
!ERROR: A variable in a DECLARE TARGET directive cannot be an element of a common block
|
|
!$omp declare target (a2)
|
|
|
|
!ERROR: A variable in a DECLARE TARGET directive cannot be an element of a common block
|
|
!$omp declare target (a3)
|
|
|
|
!ERROR: A variable that appears in a DECLARE TARGET directive must be declared in the scope of a module or have the SAVE attribute, either explicitly or implicitly
|
|
!$omp declare target to (arr2_to)
|
|
|
|
!$omp declare target to (arr3_to)
|
|
|
|
!ERROR: A variable in a DECLARE TARGET directive cannot be an element of a common block
|
|
!$omp declare target to (a2_to)
|
|
|
|
!ERROR: A variable in a DECLARE TARGET directive cannot be an element of a common block
|
|
!$omp declare target to (a3_to)
|
|
|
|
!ERROR: A variable that appears in a DECLARE TARGET directive must be declared in the scope of a module or have the SAVE attribute, either explicitly or implicitly
|
|
!$omp declare target link (arr2_link)
|
|
|
|
!$omp declare target link (arr3_link)
|
|
|
|
!ERROR: A variable in a DECLARE TARGET directive cannot be an element of a common block
|
|
!$omp declare target link (a2_link)
|
|
|
|
!ERROR: A variable in a DECLARE TARGET directive cannot be an element of a common block
|
|
!$omp declare target link (a3_link)
|
|
end
|
|
end
|
|
|
|
module mod4
|
|
integer :: arr4(10), arr4_to(10), arr4_link(10)
|
|
common /blk4/ a4, a4_to, a4_link
|
|
|
|
!$omp declare target (arr4)
|
|
|
|
!$omp declare target (blk4)
|
|
|
|
!ERROR: A variable in a DECLARE TARGET directive cannot be an element of a common block
|
|
!$omp declare target (a4)
|
|
|
|
!$omp declare target to (arr4_to)
|
|
|
|
!$omp declare target to (blk4_to)
|
|
|
|
!ERROR: A variable in a DECLARE TARGET directive cannot be an element of a common block
|
|
!$omp declare target to (a4_to)
|
|
|
|
!$omp declare target link (arr4_link)
|
|
|
|
!$omp declare target link (blk4_link)
|
|
|
|
!ERROR: A variable in a DECLARE TARGET directive cannot be an element of a common block
|
|
!$omp declare target link (a4_link)
|
|
end
|
|
|
|
subroutine func5()
|
|
integer :: arr5(10), arr5_to(10), arr5_link(10)
|
|
common /blk5/ a5, a5_to, a5_link
|
|
|
|
!ERROR: A variable that appears in a DECLARE TARGET directive must be declared in the scope of a module or have the SAVE attribute, either explicitly or implicitly
|
|
!$omp declare target (arr5)
|
|
|
|
!ERROR: A variable that appears in a DECLARE TARGET directive must be declared in the scope of a module or have the SAVE attribute, either explicitly or implicitly
|
|
!$omp declare target (blk5)
|
|
|
|
!ERROR: A variable in a DECLARE TARGET directive cannot be an element of a common block
|
|
!$omp declare target (a5)
|
|
|
|
!ERROR: A variable that appears in a DECLARE TARGET directive must be declared in the scope of a module or have the SAVE attribute, either explicitly or implicitly
|
|
!$omp declare target to (arr5_to)
|
|
|
|
!ERROR: A variable that appears in a DECLARE TARGET directive must be declared in the scope of a module or have the SAVE attribute, either explicitly or implicitly
|
|
!$omp declare target to (blk5_to)
|
|
|
|
!ERROR: A variable in a DECLARE TARGET directive cannot be an element of a common block
|
|
!$omp declare target to (a5_to)
|
|
|
|
!ERROR: A variable that appears in a DECLARE TARGET directive must be declared in the scope of a module or have the SAVE attribute, either explicitly or implicitly
|
|
!$omp declare target link (arr5_link)
|
|
|
|
!ERROR: A variable that appears in a DECLARE TARGET directive must be declared in the scope of a module or have the SAVE attribute, either explicitly or implicitly
|
|
!$omp declare target link (blk5_link)
|
|
|
|
!ERROR: A variable in a DECLARE TARGET directive cannot be an element of a common block
|
|
!$omp declare target link (a5_link)
|
|
end
|