Debian Codegraph @

gcc/testsuite/g++.dg/gomp/bad-array-section-7.C

raw
1 // { dg-do compile }
2
3 int x;
4
5 template<typename T>
6 void foo()
7 {
8 T arr[20];
9 // Here we know the type of the array section (the upper bound is reported)...
10 #pragma omp target map(arr[5:5] * 2)
11 // { dg-error {invalid operands of types 'int \[10\]' and 'int'} "" { target *-*-* } .-1 }
12 { }
13 /* ...but here, we have an incomplete array type because of the variable
14 low bound 'x'. */
15 #pragma omp target map(arr[x:5] * 2)
16 // { dg-error {invalid operands of types 'int \[\]' and 'int'} "" { target *-*-* } .-1 }
17 { }
18 }
19
20 int main()
21 {
22 int arr[20];
23 // Here we know the type of the array section (the upper bound is reported)...
24 #pragma omp target map(arr[5:5] * 2)
25 // { dg-error {invalid operands of types 'int \[10\]' and 'int'} "" { target *-*-* } .-1 }
26 { }
27 /* ...but here, we have an incomplete array type because of the variable
28 low bound 'x'. */
29 #pragma omp target map(arr[x:5] * 2)
30 // { dg-error {invalid operands of types 'int \[\]' and 'int'} "" { target *-*-* } .-1 }
31 { }
32
33 foo<int> ();
34
35 return 0;
36 }