Debian Codegraph @

gcc/testsuite/g++.dg/goacc/cache-3-2.C

raw
1 /* Test 'cache' directive diagnostics. */
2
3 /* See also corresponding C/C++ variant: '../../c-c++-common/goacc/cache-3-2.c'. */
4
5 /* See also corresponding C++ data clause variant: 'data-clause-2.C'. */
6
7 /* The current implementation doesn't restrict where a 'cache' directive may
8 appear, so we don't make any special arrangements. */
9
10 template <int N>
11 void
12 foo (int *p, int (*q)[10], int r[10], int s[10][10])
13 {
14 int a[10], b[10][10];
15 #pragma acc cache (p[-1:2])
16 ;
17 #pragma acc cache (q[-1:2][0:10])
18 ;
19 #pragma acc cache (q[-1:2][-2:10]) /* { dg-error "negative low bound in array section in" } */
20 ;
21 #pragma acc cache (r[-1:2])
22 ;
23 #pragma acc cache (s[-1:2][:])
24 ;
25 #pragma acc cache (s[-1:2][-2:10]) /* { dg-error "negative low bound in array section in" } */
26 ;
27 #pragma acc cache (a[-1:2]) /* { dg-error "negative low bound in array section in" } */
28 ;
29 #pragma acc cache (b[-1:2][0:]) /* { dg-error "negative low bound in array section in" } */
30 ;
31 #pragma acc cache (b[1:2][-2:10]) /* { dg-error "negative low bound in array section in" } */
32 ;
33 #pragma acc cache (p[2:-3]) /* { dg-error "negative length in array section in" } */
34 ;
35 #pragma acc cache (q[2:-3][:]) /* { dg-error "negative length in array section in" } */
36 ;
37 #pragma acc cache (q[2:3][0:-1]) /* { dg-error "negative length in array section in" } */
38 ;
39 #pragma acc cache (r[2:-5]) /* { dg-error "negative length in array section in" } */
40 ;
41 #pragma acc cache (s[2:-5][:]) /* { dg-error "negative length in array section in" } */
42 ;
43 #pragma acc cache (s[2:5][0:-4]) /* { dg-error "negative length in array section in" } */
44 ;
45 #pragma acc cache (a[2:-5]) /* { dg-error "negative length in array section in" } */
46 ;
47 #pragma acc cache (b[2:-5][0:10]) /* { dg-error "negative length in array section in" } */
48 ;
49 #pragma acc cache (b[2:5][0:-4]) /* { dg-error "negative length in array section in" } */
50 ;
51 }
52
53 static void
54 instantiate ()
55 {
56 &foo<0>;
57 }