xref: /llvm-project/clang/test/ParserOpenACC/parse-cache-construct.c (revision c1298878175f1f6b7f991a18550de97a699cf260)
1721558aeSErich Keane // RUN: %clang_cc1 %s -verify -fopenacc
2721558aeSErich Keane 
3cac6b1a5SErich Keane struct S {
4cac6b1a5SErich Keane   int foo;
5cac6b1a5SErich Keane   char Array[1];
6cac6b1a5SErich Keane };
7721558aeSErich Keane char *getArrayPtr();
func()8721558aeSErich Keane void func() {
9721558aeSErich Keane   char Array[10];
10721558aeSErich Keane   char *ArrayPtr = getArrayPtr();
11721558aeSErich Keane   int *readonly;
12cac6b1a5SErich Keane   struct S s;
13721558aeSErich Keane 
14721558aeSErich Keane   for (int i = 0; i < 10; ++i) {
15721558aeSErich Keane     // expected-error@+2{{expected '('}}
16db4ea21dSerichkeane     // expected-warning@+1{{OpenACC construct 'cache' not yet implemented, pragma ignored}}
17721558aeSErich Keane     #pragma acc cache
18721558aeSErich Keane   }
19721558aeSErich Keane 
20721558aeSErich Keane   for (int i = 0; i < 10; ++i) {
21721558aeSErich Keane     // expected-error@+3{{expected '('}}
22fdee0a35SErich Keane     // expected-error@+2{{invalid OpenACC clause 'clause'}}
23db4ea21dSerichkeane     // expected-warning@+1{{OpenACC construct 'cache' not yet implemented, pragma ignored}}
24721558aeSErich Keane     #pragma acc cache clause list
25721558aeSErich Keane   }
26721558aeSErich Keane 
27721558aeSErich Keane   for (int i = 0; i < 10; ++i) {
28fa67986dSErich Keane     // expected-error@+2{{expected expression}}
29db4ea21dSerichkeane     // expected-warning@+1{{OpenACC construct 'cache' not yet implemented, pragma ignored}}
30721558aeSErich Keane     #pragma acc cache()
31721558aeSErich Keane   }
32721558aeSErich Keane 
33721558aeSErich Keane   for (int i = 0; i < 10; ++i) {
34fa67986dSErich Keane     // expected-error@+3{{expected expression}}
35fdee0a35SErich Keane     // expected-error@+2{{invalid OpenACC clause 'clause'}}
36db4ea21dSerichkeane     // expected-warning@+1{{OpenACC construct 'cache' not yet implemented, pragma ignored}}
37721558aeSErich Keane     #pragma acc cache() clause-list
38721558aeSErich Keane   }
39721558aeSErich Keane 
40721558aeSErich Keane   for (int i = 0; i < 10; ++i) {
41721558aeSErich Keane     // expected-error@+3{{expected ')'}}
42721558aeSErich Keane     // expected-note@+2{{to match this '('}}
43db4ea21dSerichkeane     // expected-warning@+1{{OpenACC construct 'cache' not yet implemented, pragma ignored}}
44721558aeSErich Keane     #pragma acc cache(
45721558aeSErich Keane   }
46721558aeSErich Keane 
47721558aeSErich Keane   for (int i = 0; i < 10; ++i) {
48721558aeSErich Keane     // expected-error@+4{{use of undeclared identifier 'invalid'}}
49721558aeSErich Keane     // expected-error@+3{{expected ')'}}
50721558aeSErich Keane     // expected-note@+2{{to match this '('}}
51db4ea21dSerichkeane     // expected-warning@+1{{OpenACC construct 'cache' not yet implemented, pragma ignored}}
52721558aeSErich Keane     #pragma acc cache(invalid
53721558aeSErich Keane   }
54721558aeSErich Keane 
55721558aeSErich Keane   for (int i = 0; i < 10; ++i) {
56721558aeSErich Keane     // expected-error@+3{{expected ')'}}
57721558aeSErich Keane     // expected-note@+2{{to match this '('}}
58db4ea21dSerichkeane     // expected-warning@+1{{OpenACC construct 'cache' not yet implemented, pragma ignored}}
59721558aeSErich Keane     #pragma acc cache(ArrayPtr
60721558aeSErich Keane   }
61721558aeSErich Keane 
62721558aeSErich Keane   for (int i = 0; i < 10; ++i) {
63721558aeSErich Keane     // expected-error@+2{{use of undeclared identifier 'invalid'}}
64db4ea21dSerichkeane     // expected-warning@+1{{OpenACC construct 'cache' not yet implemented, pragma ignored}}
65721558aeSErich Keane     #pragma acc cache(invalid)
66721558aeSErich Keane   }
67721558aeSErich Keane 
68721558aeSErich Keane   for (int i = 0; i < 10; ++i) {
69db4ea21dSerichkeane     // expected-warning@+1{{OpenACC construct 'cache' not yet implemented, pragma ignored}}
70721558aeSErich Keane     #pragma acc cache(ArrayPtr)
71721558aeSErich Keane   }
72721558aeSErich Keane 
73721558aeSErich Keane   for (int i = 0; i < 10; ++i) {
74cac6b1a5SErich Keane     // expected-error@+6{{expected expression}}
75cac6b1a5SErich Keane     // expected-error@+5{{expected ']'}}
76cac6b1a5SErich Keane     // expected-note@+4{{to match this '['}}
77721558aeSErich Keane     // expected-error@+3{{expected ')'}}
78721558aeSErich Keane     // expected-note@+2{{to match this '('}}
79db4ea21dSerichkeane     // expected-warning@+1{{OpenACC construct 'cache' not yet implemented, pragma ignored}}
80721558aeSErich Keane     #pragma acc cache(ArrayPtr[
81721558aeSErich Keane   }
82721558aeSErich Keane 
83721558aeSErich Keane   for (int i = 0; i < 10; ++i) {
84cac6b1a5SErich Keane     // expected-error@+4{{expected expression}}
85cac6b1a5SErich Keane     // expected-error@+3{{expected ']'}}
86cac6b1a5SErich Keane     // expected-note@+2{{to match this '['}}
87db4ea21dSerichkeane     // expected-warning@+1{{OpenACC construct 'cache' not yet implemented, pragma ignored}}
88721558aeSErich Keane     #pragma acc cache(ArrayPtr[, 5)
89721558aeSErich Keane   }
90721558aeSErich Keane 
91721558aeSErich Keane   for (int i = 0; i < 10; ++i) {
92cac6b1a5SErich Keane     // expected-error@+4{{expected expression}}
93cac6b1a5SErich Keane     // expected-error@+3{{expected ']'}}
94cac6b1a5SErich Keane     // expected-note@+2{{to match this '['}}
95db4ea21dSerichkeane     // expected-warning@+1{{OpenACC construct 'cache' not yet implemented, pragma ignored}}
96721558aeSErich Keane     #pragma acc cache(Array[)
97721558aeSErich Keane   }
98721558aeSErich Keane 
99721558aeSErich Keane   for (int i = 0; i < 10; ++i) {
100db4ea21dSerichkeane     // expected-warning@+1{{OpenACC construct 'cache' not yet implemented, pragma ignored}}
101721558aeSErich Keane     #pragma acc cache(Array[*readonly])
102721558aeSErich Keane   }
103721558aeSErich Keane 
104721558aeSErich Keane   for (int i = 0; i < 10; ++i) {
105cac6b1a5SErich Keane     // expected-error@+6{{expected expression}}
106cac6b1a5SErich Keane     // expected-error@+5{{expected ']'}}
107cac6b1a5SErich Keane     // expected-note@+4{{to match this '['}}
108721558aeSErich Keane     // expected-error@+3{{expected ')'}}
109721558aeSErich Keane     // expected-note@+2{{to match this '('}}
110db4ea21dSerichkeane     // expected-warning@+1{{OpenACC construct 'cache' not yet implemented, pragma ignored}}
111721558aeSErich Keane     #pragma acc cache(Array[*readonly:
112721558aeSErich Keane   }
113721558aeSErich Keane 
114721558aeSErich Keane   for (int i = 0; i < 10; ++i) {
115db4ea21dSerichkeane     // expected-warning@+1{{OpenACC construct 'cache' not yet implemented, pragma ignored}}
116721558aeSErich Keane     #pragma acc cache(readonly)
117721558aeSErich Keane   }
118721558aeSErich Keane 
119721558aeSErich Keane   for (int i = 0; i < 10; ++i) {
1209e068cd7SErich Keane     // expected-error@+2{{invalid tag 'devnum' on 'cache' directive}}
121db4ea21dSerichkeane     // expected-warning@+1{{OpenACC construct 'cache' not yet implemented, pragma ignored}}
1229e068cd7SErich Keane     #pragma acc cache(devnum:ArrayPtr)
1239e068cd7SErich Keane   }
1249e068cd7SErich Keane 
1259e068cd7SErich Keane   for (int i = 0; i < 10; ++i) {
1269e068cd7SErich Keane     // expected-error@+2{{invalid tag 'invalid' on 'cache' directive}}
127db4ea21dSerichkeane     // expected-warning@+1{{OpenACC construct 'cache' not yet implemented, pragma ignored}}
1289e068cd7SErich Keane     #pragma acc cache(invalid:ArrayPtr)
1299e068cd7SErich Keane   }
1309e068cd7SErich Keane 
1319e068cd7SErich Keane   for (int i = 0; i < 10; ++i) {
132db4ea21dSerichkeane     // expected-warning@+1{{OpenACC construct 'cache' not yet implemented, pragma ignored}}
133721558aeSErich Keane     #pragma acc cache(readonly:ArrayPtr)
134721558aeSErich Keane   }
135721558aeSErich Keane 
136721558aeSErich Keane   for (int i = 0; i < 10; ++i) {
137db4ea21dSerichkeane     // expected-warning@+1{{OpenACC construct 'cache' not yet implemented, pragma ignored}}
138*c1298878SErich Keane     #pragma acc cache(readonly:ArrayPtr[5:1])
139721558aeSErich Keane   }
140721558aeSErich Keane 
141721558aeSErich Keane   for (int i = 0; i < 10; ++i) {
142db4ea21dSerichkeane     // expected-warning@+1{{OpenACC construct 'cache' not yet implemented, pragma ignored}}
143721558aeSErich Keane     #pragma acc cache(readonly:ArrayPtr[5:*readonly])
144721558aeSErich Keane   }
145721558aeSErich Keane 
146721558aeSErich Keane   for (int i = 0; i < 10; ++i) {
147db4ea21dSerichkeane     // expected-warning@+1{{OpenACC construct 'cache' not yet implemented, pragma ignored}}
148721558aeSErich Keane     #pragma acc cache(readonly:ArrayPtr[5:*readonly], Array)
149721558aeSErich Keane   }
150721558aeSErich Keane 
151721558aeSErich Keane   for (int i = 0; i < 10; ++i) {
152db4ea21dSerichkeane     // expected-warning@+1{{OpenACC construct 'cache' not yet implemented, pragma ignored}}
153721558aeSErich Keane     #pragma acc cache(readonly:ArrayPtr[5:*readonly], Array[*readonly:3])
154721558aeSErich Keane   }
155721558aeSErich Keane 
156721558aeSErich Keane   for (int i = 0; i < 10; ++i) {
157db4ea21dSerichkeane     // expected-warning@+1{{OpenACC construct 'cache' not yet implemented, pragma ignored}}
158721558aeSErich Keane     #pragma acc cache(readonly:ArrayPtr[5 + i:*readonly], Array[*readonly + i:3])
159721558aeSErich Keane   }
160721558aeSErich Keane 
161721558aeSErich Keane   for (int i = 0; i < 10; ++i) {
162cac6b1a5SErich Keane     // expected-error@+4{{expected expression}}
163721558aeSErich Keane     // expected-error@+3{{expected ')'}}
164721558aeSErich Keane     // expected-note@+2{{to match this '('}}
165db4ea21dSerichkeane     // expected-warning@+1{{OpenACC construct 'cache' not yet implemented, pragma ignored}}
166721558aeSErich Keane     #pragma acc cache(readonly:ArrayPtr[5:*readonly],
167721558aeSErich Keane   }
168721558aeSErich Keane 
169721558aeSErich Keane   for (int i = 0; i < 10; ++i) {
170cac6b1a5SErich Keane     // expected-error@+2{{expected expression}}
171db4ea21dSerichkeane     // expected-warning@+1{{OpenACC construct 'cache' not yet implemented, pragma ignored}}
172721558aeSErich Keane     #pragma acc cache(readonly:ArrayPtr[5:*readonly],)
173721558aeSErich Keane   }
174721558aeSErich Keane 
175721558aeSErich Keane   for (int i = 0; i < 10; ++i) {
176721558aeSErich Keane     // expected-warning@+2{{left operand of comma operator has no effect}}
177db4ea21dSerichkeane     // expected-warning@+1{{OpenACC construct 'cache' not yet implemented, pragma ignored}}
178721558aeSErich Keane     #pragma acc cache(readonly:ArrayPtr[5,6:*readonly])
179721558aeSErich Keane   }
180721558aeSErich Keane 
181721558aeSErich Keane   for (int i = 0; i < 10; ++i) {
182721558aeSErich Keane     // expected-warning@+2{{left operand of comma operator has no effect}}
183db4ea21dSerichkeane     // expected-warning@+1{{OpenACC construct 'cache' not yet implemented, pragma ignored}}
184721558aeSErich Keane     #pragma acc cache(readonly:ArrayPtr[5:3, *readonly], ArrayPtr[0])
185721558aeSErich Keane   }
186721558aeSErich Keane 
187cac6b1a5SErich Keane   for (int i = 0; i < 10; ++i) {
188db4ea21dSerichkeane     // expected-warning@+1{{OpenACC construct 'cache' not yet implemented, pragma ignored}}
189cac6b1a5SErich Keane     #pragma acc cache(readonly:s.foo)
190cac6b1a5SErich Keane   }
191cac6b1a5SErich Keane 
192cac6b1a5SErich Keane   for (int i = 0; i < 10; ++i) {
193cac6b1a5SErich Keane     // expected-warning@+2{{left operand of comma operator has no effect}}
194db4ea21dSerichkeane     // expected-warning@+1{{OpenACC construct 'cache' not yet implemented, pragma ignored}}
195cac6b1a5SErich Keane     #pragma acc cache(readonly:s.Array[1,2])
196cac6b1a5SErich Keane   }
197721558aeSErich Keane }
198