@@ -11889,6 +11889,15 @@ handle_omp_array_sections_1 (tree c, tre
"for pointer type length expression must be specified");
return error_mark_node;
}
+ if (length != NULL_TREE
+ && TREE_CODE (length) == INTEGER_CST
+ && tree_int_cst_sgn (length) == -1)
+ {
+ error_at (OMP_CLAUSE_LOCATION (c),
+ "negative length in array section in %qs clause",
+ omp_clause_code_name[OMP_CLAUSE_CODE (c)]);
+ return error_mark_node;
+ }
/* If there is a pointer type anywhere but in the very first
array-section-subscript, the array section can't be contiguous. */
if (OMP_CLAUSE_CODE (c) != OMP_CLAUSE_DEPEND
@@ -4668,6 +4668,15 @@ handle_omp_array_sections_1 (tree c, tre
"for pointer type length expression must be specified");
return error_mark_node;
}
+ if (length != NULL_TREE
+ && TREE_CODE (length) == INTEGER_CST
+ && tree_int_cst_sgn (length) == -1)
+ {
+ error_at (OMP_CLAUSE_LOCATION (c),
+ "negative length in array section in %qs clause",
+ omp_clause_code_name[OMP_CLAUSE_CODE (c)]);
+ return error_mark_node;
+ }
/* If there is a pointer type anywhere but in the very first
array-section-subscript, the array section can't be contiguous. */
if (OMP_CLAUSE_CODE (c) != OMP_CLAUSE_DEPEND
@@ -23,4 +23,22 @@ foo (int *p, int (*q)[10], int r[10], in
;
#pragma omp task depend (inout: b[1:2][-2:4]) /* { dg-error "negative low bound in array section in" } */
;
+ #pragma omp task depend (inout: p[2:-3]) /* { dg-error "negative length in array section in" } */
+ ;
+ #pragma omp task depend (inout: q[2:-3][:]) /* { dg-error "negative length in array section in" } */
+ ;
+ #pragma omp task depend (inout: q[2:3][0:-1]) /* { dg-error "negative length in array section in" } */
+ ;
+ #pragma omp task depend (inout: r[2:-5]) /* { dg-error "negative length in array section in" } */
+ ;
+ #pragma omp task depend (inout: s[2:-5][:]) /* { dg-error "negative length in array section in" } */
+ ;
+ #pragma omp task depend (inout: s[2:5][0:-4]) /* { dg-error "negative length in array section in" } */
+ ;
+ #pragma omp task depend (inout: a[2:-5]) /* { dg-error "negative length in array section in" } */
+ ;
+ #pragma omp task depend (inout: b[2:-5][0:10]) /* { dg-error "negative length in array section in" } */
+ ;
+ #pragma omp task depend (inout: b[2:5][0:-4]) /* { dg-error "negative length in array section in" } */
+ ;
}
@@ -23,4 +23,22 @@ foo (int *p, int (*q)[10], int r[10], in
;
#pragma omp target map (tofrom: b[1:2][-2:10]) /* { dg-error "negative low bound in array section in" } */
;
+ #pragma omp target map (tofrom: p[2:-3]) /* { dg-error "negative length in array section in" } */
+ ;
+ #pragma omp target map (tofrom: q[2:-3][:]) /* { dg-error "negative length in array section in" } */
+ ;
+ #pragma omp target map (tofrom: q[2:3][0:-1]) /* { dg-error "negative length in array section in" } */
+ ;
+ #pragma omp target map (tofrom: r[2:-5]) /* { dg-error "negative length in array section in" } */
+ ;
+ #pragma omp target map (tofrom: s[2:-5][:]) /* { dg-error "negative length in array section in" } */
+ ;
+ #pragma omp target map (tofrom: s[2:5][0:-4]) /* { dg-error "negative length in array section in" } */
+ ;
+ #pragma omp target map (tofrom: a[2:-5]) /* { dg-error "negative length in array section in" } */
+ ;
+ #pragma omp target map (tofrom: b[2:-5][0:10]) /* { dg-error "negative length in array section in" } */
+ ;
+ #pragma omp target map (tofrom: b[2:5][0:-4]) /* { dg-error "negative length in array section in" } */
+ ;
}