Debian Codegraph @

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

raw
1 // { dg-do compile }
2
3 int x;
4
5 template<typename X>
6 struct Tt {
7 X arr[20];
8 };
9
10 template<typename X>
11 struct St {
12 X *tvec;
13 };
14
15 template<typename T>
16 void foo()
17 {
18 struct St<Tt<T> > *s;
19 // You can't use an array section like this. Make sure sensible errors are
20 // reported.
21 #pragma omp target map(s->tvec[3:5].arr[0:20])
22 // { dg-error {request for member 'arr' in 's->St<Tt<int> >::tvec\[3:5\]', which is of non-class type 'Tt<int> \[8\]'} "" { target *-*-* } .-1 }
23 { }
24 #pragma omp target map(s->tvec[5:x].arr[0:20])
25 // { dg-error {invalid use of array with unspecified bounds} "" { target *-*-* } .-1 }
26 { }
27 }
28
29 struct T {
30 int arr[20];
31 };
32
33 struct S {
34 struct T *tvec;
35 };
36
37 int main()
38 {
39 struct S *s;
40 // You can't use an array section like this. Make sure sensible errors are
41 // reported.
42 #pragma omp target map(s->tvec[3:5].arr[0:20])
43 // { dg-error {request for member 'arr' in 's->S::tvec\[3:5\]', which is of non-class type 'T \[8\]'} "" { target *-*-* } .-1 }
44 { }
45 #pragma omp target map(s->tvec[5:x].arr[0:20])
46 // { dg-error {invalid use of array with unspecified bounds} "" { target *-*-* } .-1 }
47 // { dg-error {expected '\)' before 'arr'} "" { target *-*-* } .-2 }
48 { }
49
50 foo<int> ();
51
52 return 0;
53 }