Debian Codegraph @

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

raw
1 /* Test 'cache' directive diagnostics. */
2
3 /* See also corresponding C/C++ variant: '../../c-c++-common/goacc/cache-3-1.c'. */
4
5 /* See also corresponding C++ data clause variant: 'data-clause-1.C'. */
6
7 /* { dg-additional-options "-fopenmp" } for '#pragma omp threadprivate'. */
8
9 /* The current implementation doesn't restrict where a 'cache' directive may
10 appear, so we don't make any special arrangements. */
11
12 extern int a[][10], a2[][10];
13 int b[10], c[10][2], d[10], e[10], f[10];
14 int b2[10], c2[10][2], d2[10], e2[10], f2[10];
15 int k[10], l[10], m[10], n[10], o;
16 int *p;
17 int **q;
18 int r[4][4][4][4][4];
19 extern struct s s1;
20 extern struct s s2[1]; /* { dg-error "array type has incomplete element type" "" { target c } } */
21 int t[10];
22 #pragma omp threadprivate (t)
23 #pragma acc routine
24 void bar (int *);
25
26 template <int N>
27 void
28 foo (int g[3][10], int h[4][8], int i[2][10], int j[][9],
29 int g2[3][10], int h2[4][8], int i2[2][10], int j2[][9])
30 {
31 #pragma acc cache(bar[2:5]) /* { dg-error "is not a variable" } */
32 ;
33 #pragma acc cache(t[2:5]) /* { dg-error "is threadprivate variable" } */
34 ;
35 #pragma acc cache(k[0.5:]) /* { dg-error "low bound \[^\n\r]* of array section does not have integral type" } */
36 ;
37 #pragma acc cache(l[:7.5f]) /* { dg-error "length \[^\n\r]* of array section does not have integral type" } */
38 ;
39 #pragma acc cache(m[p:]) /* { dg-error "low bound \[^\n\r]* of array section does not have integral type" } */
40 ;
41 #pragma acc cache(n[:p]) /* { dg-error "length \[^\n\r]* of array section does not have integral type" } */
42 ;
43 #pragma acc cache(o[2:5]) /* { dg-error "does not have pointer or array type" } */
44 ;
45 #pragma acc cache(s1) /* { dg-error "expected '\\\['" } */
46 ;
47 #pragma acc cache(s2) /* { dg-error "expected '\\\['" } */
48 ;
49 #pragma acc cache(a[:][:]) /* { dg-error "array type length expression must be specified" } */
50 bar (&a[0][0]);
51 #pragma acc cache(b[-1:]) /* { dg-error "negative low bound in array section" } */
52 bar (b);
53 #pragma acc cache(c[:-3][:]) /* { dg-error "negative length in array section" } */
54 bar (&c[0][0]);
55 #pragma acc cache(d[11:]) /* { dg-error "low bound \[^\n\r]* above array section size" } */
56 bar (d);
57 #pragma acc cache(e[:11]) /* { dg-error "length \[^\n\r]* above array section size" } */
58 bar (e);
59 #pragma acc cache(f[1:10]) /* { dg-error "high bound \[^\n\r]* above array section size" } */
60 bar (f);
61 #pragma acc cache(g[:][0:10]) /* { dg-error "for array function parameter length expression must be specified" } */
62 bar (&g[0][0]);
63 #pragma acc cache(h[2:1][-1:]) /* { dg-error "negative low bound in array section" } */
64 bar (&h[0][0]);
65 #pragma acc cache(h[:1][:-3]) /* { dg-error "negative length in array section" } */
66 bar (&h[0][0]);
67 #pragma acc cache(i[:1][11:]) /* { dg-error "low bound \[^\n\r]* above array section size" } */
68 bar (&i[0][0]);
69 #pragma acc cache(j[3:1][:10]) /* { dg-error "length \[^\n\r]* above array section size" } */
70 bar (&j[0][0]);
71 #pragma acc cache(j[30:1][5:5]) /* { dg-error "high bound \[^\n\r]* above array section size" } */
72 bar (&j[0][0]);
73 #pragma acc cache(a2[:1][2:4])
74 bar (&a2[0][0]);
75 #pragma acc cache(a2[3:5][:])
76 bar (&a2[0][0]);
77 #pragma acc cache(a2[3:5][:10])
78 bar (&a2[0][0]);
79 #pragma acc cache(b2[0:])
80 bar (b2);
81 #pragma acc cache(c2[:3][:])
82 bar (&c2[0][0]);
83 #pragma acc cache(d2[9:])
84 bar (d2);
85 #pragma acc cache(e2[:10])
86 bar (e2);
87 #pragma acc cache(f2[1:9])
88 bar (f2);
89 #pragma acc cache(g2[:1][2:4])
90 bar (&g2[0][0]);
91 #pragma acc cache(h2[2:2][0:])
92 bar (&h2[0][0]);
93 #pragma acc cache(h2[:1][:3])
94 bar (&h2[0][0]);
95 #pragma acc cache(i2[:1][9:])
96 bar (&i2[0][0]);
97 #pragma acc cache(j2[3:4][:9])
98 bar (&j2[0][0]);
99 #pragma acc cache(j2[30:1][5:4])
100 bar (&j2[0][0]);
101 #pragma acc cache(q[1:2])
102 ;
103 #pragma acc cache(q[3:5][:10]) /* { dg-error "array section is not contiguous" } */
104 ;
105 #pragma acc cache(r[3:][2:1][1:2])
106 ;
107 #pragma acc cache(r[3:][2:1][1:2][:][0:4])
108 ;
109 #pragma acc cache(r[3:][2:1][1:2][1:][0:4]) /* { dg-error "array section is not contiguous" } */
110 ;
111 #pragma acc cache(r[3:][2:1][1:2][:3][0:4]) /* { dg-error "array section is not contiguous" } */
112 ;
113 #pragma acc cache(r[3:][2:1][1:2][:][1:]) /* { dg-error "array section is not contiguous" } */
114 ;
115 #pragma acc cache(r[3:][2:1][1:2][:][:3]) /* { dg-error "array section is not contiguous" } */
116 ;
117 }
118
119 static void
120 instantiate ()
121 {
122 &foo<0>;
123 }