You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[clang][OpenMP] 6.0: detect privatization of array section/assumed-size array
According to the OpenMP 6.0 specification, array sections with no length
and unknown size are considered assumed-size arrays. As of pull request
llvm#148048
these types of array sections are allowed and can be specified in clauses
that allow array sections as list items. However, only two clauses
explicitly allow array sections that are assumed-size arrays:
- 'map' and 'use_device_addr'.
The other clauses that accept array sections do not explicitly accept
assumed-size arrays:
- inclusive, exclusive, has_device_addr, in_reduction, task_reduction,
reduction
These cases should generate an error. See OpenMP 6.0 specification
section 7.4 List Item Privatization, Restrictions, p. 222, L15
Assumed-size arrays must not be privatized
For OpenMP 6.0, function getPrivateItem() now checks for array section list
items that are assumed-size arrays and generates an error if they are not
allowed for the clause.
Testing
- Updated LIT tests for assumed-size array sections to ensure these
clauses generate an error:
inclusive, exclusive, has_device_addr, in_reduction, task_reduction,
reduction
and that this clause is accepted (codegen test):
use_device_addr
- check-all
- OpenMP_VV (sollve_vv)
#pragma omp scan // expected-error {{exactly one of 'inclusive' or 'exclusive' clauses is expected}}
@@ -83,12 +88,23 @@ T tmain() {
83
88
label1 : {
84
89
#pragma omp scan inclusive(argc) // expected-error {{orphaned 'omp scan' directives are prohibited; perhaps you forget to enclose the directive into a for, simd, for simd, parallel for, or parallel for simd region?}}
85
90
}}
91
+
#pragma omp simd reduction(inscan, +: argc)
92
+
for (int i = 0; i < 10; ++i) {
93
+
#pragma omp scan inclusive(ptr[0:], argc) // expected-error {{section length is unspecified and cannot be inferred because subscripted value is not an array}}
94
+
;
95
+
}
96
+
#pragma omp simd reduction(inscan, +: argc)
97
+
for (int i = 0; i < 10; ++i) {
98
+
#pragma omp scan exclusive(argc, ub[:]) // expected-error {{section length is unspecified and cannot be inferred because subscripted value is an array of unknown bound}}
99
+
;
100
+
}
86
101
87
102
returnT();
88
103
}
89
104
90
-
intmain() {
105
+
intfoobar(int ub[]) {
91
106
staticint argc;
107
+
int *ptr;
92
108
#pragma omp simd reduction(inscan, +: argc)
93
109
for (int i = 0; i < 10; ++i) {
94
110
#pragma omp scan inclusive(argc) inclusive(argc) // expected-error {{exactly one of 'inclusive' or 'exclusive' clauses is expected}}
@@ -177,6 +193,16 @@ label1 : {
177
193
#pragma omp scan inclusive(argc) // expected-error {{orphaned 'omp scan' directives are prohibited; perhaps you forget to enclose the directive into a for, simd, for simd, parallel for, or parallel for simd region?}}
178
194
}
179
195
}
196
+
#pragma omp simd reduction(inscan, +: argc)
197
+
for (int i = 0; i < 10; ++i) {
198
+
#pragma omp scan inclusive(ptr[0:], argc) // expected-error {{section length is unspecified and cannot be inferred because subscripted value is not an array}}
199
+
;
200
+
}
201
+
#pragma omp simd reduction(inscan, +: argc)
202
+
for (int i = 0; i < 10; ++i) {
203
+
#pragma omp scan exclusive(argc, ub[:]) // expected-error {{section length is unspecified and cannot be inferred because subscripted value is an array of unknown bound}}
204
+
;
205
+
}
180
206
181
-
returntmain<int>(); // expected-note {{in instantiation of function template specialization 'tmain<int>' requested here}}
207
+
returntfoobar<int>(ub); // expected-note {{in instantiation of function template specialization 'tfoobar<int>' requested here}}
0 commit comments