[flang] Accept polymorphic component element in storage_size
[llvm-project.git] / flang / test / Semantics / OpenMP / omp-declare-target02.f90
blob57a2776ff934054a0616e03bffea800b3b1ba0dd
1 ! RUN: %python %S/../test_errors.py %s %flang_fc1 -fopenmp
2 ! OpenMP Version 5.1
3 ! Check OpenMP construct validity for the following directives:
4 ! 2.14.7 Declare Target Directive
6 program declare_target02
7 integer :: arr1(10), arr1_to(10), arr1_link(10)
8 common /blk1/ a1, a1_to, a1_link
9 real, save :: eq_a, eq_b, eq_c, eq_d
12 !$omp declare target (arr1)
14 !$omp declare target (blk1)
16 !ERROR: A variable in a DECLARE TARGET directive cannot be an element of a common block
17 !$omp declare target (a1)
19 !$omp declare target to (arr1_to)
21 !$omp declare target to (blk1_to)
23 !ERROR: A variable in a DECLARE TARGET directive cannot be an element of a common block
24 !$omp declare target to (a1_to)
26 !$omp declare target link (arr1_link)
28 !$omp declare target link (blk1_link)
30 !ERROR: A variable in a DECLARE TARGET directive cannot be an element of a common block
31 !$omp declare target link (a1_link)
33 equivalence(eq_a, eq_b)
34 !ERROR: A variable in a DECLARE TARGET directive cannot appear in an EQUIVALENCE statement
35 !$omp declare target (eq_a)
37 !ERROR: A variable in a DECLARE TARGET directive cannot appear in an EQUIVALENCE statement
38 !$omp declare target to (eq_a)
40 !ERROR: A variable in a DECLARE TARGET directive cannot appear in an EQUIVALENCE statement
41 !$omp declare target link (eq_b)
43 !ERROR: A variable in a DECLARE TARGET directive cannot appear in an EQUIVALENCE statement
44 !$omp declare target (eq_c)
46 !ERROR: A variable in a DECLARE TARGET directive cannot appear in an EQUIVALENCE statement
47 !$omp declare target to (eq_c)
49 !ERROR: A variable in a DECLARE TARGET directive cannot appear in an EQUIVALENCE statement
50 !$omp declare target link (eq_d)
51 equivalence(eq_c, eq_d)
53 contains
54 subroutine func()
55 integer :: arr2(10), arr2_to(10), arr2_link(10)
56 integer, save :: arr3(10), arr3_to(10), arr3_link(10)
57 common /blk2/ a2, a2_to, a2_link
58 common /blk3/ a3, a3_to, a3_link
59 save /blk3/
61 !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
62 !$omp declare target (arr2)
64 !$omp declare target (arr3)
66 !ERROR: A variable in a DECLARE TARGET directive cannot be an element of a common block
67 !$omp declare target (a2)
69 !ERROR: A variable in a DECLARE TARGET directive cannot be an element of a common block
70 !$omp declare target (a3)
72 !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
73 !$omp declare target to (arr2_to)
75 !$omp declare target to (arr3_to)
77 !ERROR: A variable in a DECLARE TARGET directive cannot be an element of a common block
78 !$omp declare target to (a2_to)
80 !ERROR: A variable in a DECLARE TARGET directive cannot be an element of a common block
81 !$omp declare target to (a3_to)
83 !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
84 !$omp declare target link (arr2_link)
86 !$omp declare target link (arr3_link)
88 !ERROR: A variable in a DECLARE TARGET directive cannot be an element of a common block
89 !$omp declare target link (a2_link)
91 !ERROR: A variable in a DECLARE TARGET directive cannot be an element of a common block
92 !$omp declare target link (a3_link)
93 end
94 end
96 module mod4
97 integer :: arr4(10), arr4_to(10), arr4_link(10)
98 common /blk4/ a4, a4_to, a4_link
100 !$omp declare target (arr4)
102 !$omp declare target (blk4)
104 !ERROR: A variable in a DECLARE TARGET directive cannot be an element of a common block
105 !$omp declare target (a4)
107 !$omp declare target to (arr4_to)
109 !$omp declare target to (blk4_to)
111 !ERROR: A variable in a DECLARE TARGET directive cannot be an element of a common block
112 !$omp declare target to (a4_to)
114 !$omp declare target link (arr4_link)
116 !$omp declare target link (blk4_link)
118 !ERROR: A variable in a DECLARE TARGET directive cannot be an element of a common block
119 !$omp declare target link (a4_link)
122 subroutine func5()
123 integer :: arr5(10), arr5_to(10), arr5_link(10)
124 common /blk5/ a5, a5_to, a5_link
126 !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
127 !$omp declare target (arr5)
129 !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
130 !$omp declare target (blk5)
132 !ERROR: A variable in a DECLARE TARGET directive cannot be an element of a common block
133 !$omp declare target (a5)
135 !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
136 !$omp declare target to (arr5_to)
138 !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
139 !$omp declare target to (blk5_to)
141 !ERROR: A variable in a DECLARE TARGET directive cannot be an element of a common block
142 !$omp declare target to (a5_to)
144 !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
145 !$omp declare target link (arr5_link)
147 !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
148 !$omp declare target link (blk5_link)
150 !ERROR: A variable in a DECLARE TARGET directive cannot be an element of a common block
151 !$omp declare target link (a5_link)