xref: /llvm-project/clang/test/ParserOpenACC/parse-cache-construct.c (revision fdee0a35d9da1febfab20ead8565cf6167103b51)
1721558aeSErich Keane // RUN: %clang_cc1 %s -verify -fopenacc
2721558aeSErich Keane 
3721558aeSErich Keane char *getArrayPtr();
4721558aeSErich Keane void func() {
5721558aeSErich Keane   char Array[10];
6721558aeSErich Keane   char *ArrayPtr = getArrayPtr();
7721558aeSErich Keane   int *readonly;
8721558aeSErich Keane 
9721558aeSErich Keane   for (int i = 0; i < 10; ++i) {
10721558aeSErich Keane     // expected-error@+2{{expected '('}}
11721558aeSErich Keane     // expected-warning@+1{{OpenACC directives not yet implemented, pragma ignored}}
12721558aeSErich Keane     #pragma acc cache
13721558aeSErich Keane   }
14721558aeSErich Keane 
15721558aeSErich Keane   for (int i = 0; i < 10; ++i) {
16721558aeSErich Keane     // expected-error@+3{{expected '('}}
17*fdee0a35SErich Keane     // expected-error@+2{{invalid OpenACC clause 'clause'}}
18721558aeSErich Keane     // expected-warning@+1{{OpenACC directives not yet implemented, pragma ignored}}
19721558aeSErich Keane     #pragma acc cache clause list
20721558aeSErich Keane   }
21721558aeSErich Keane 
22721558aeSErich Keane   for (int i = 0; i < 10; ++i) {
23721558aeSErich Keane     // expected-warning@+1{{OpenACC directives not yet implemented, pragma ignored}}
24721558aeSErich Keane     #pragma acc cache()
25721558aeSErich Keane   }
26721558aeSErich Keane 
27721558aeSErich Keane   for (int i = 0; i < 10; ++i) {
28*fdee0a35SErich Keane     // expected-error@+2{{invalid OpenACC clause 'clause'}}
29721558aeSErich Keane     // expected-warning@+1{{OpenACC directives not yet implemented, pragma ignored}}
30721558aeSErich Keane     #pragma acc cache() clause-list
31721558aeSErich Keane   }
32721558aeSErich Keane 
33721558aeSErich Keane   for (int i = 0; i < 10; ++i) {
34721558aeSErich Keane     // expected-error@+3{{expected ')'}}
35721558aeSErich Keane     // expected-note@+2{{to match this '('}}
36721558aeSErich Keane     // expected-warning@+1{{OpenACC directives not yet implemented, pragma ignored}}
37721558aeSErich Keane     #pragma acc cache(
38721558aeSErich Keane   }
39721558aeSErich Keane 
40721558aeSErich Keane   for (int i = 0; i < 10; ++i) {
41721558aeSErich Keane     // expected-error@+4{{use of undeclared identifier 'invalid'}}
42721558aeSErich Keane     // expected-error@+3{{expected ')'}}
43721558aeSErich Keane     // expected-note@+2{{to match this '('}}
44721558aeSErich Keane     // expected-warning@+1{{OpenACC directives not yet implemented, pragma ignored}}
45721558aeSErich Keane     #pragma acc cache(invalid
46721558aeSErich Keane   }
47721558aeSErich Keane 
48721558aeSErich Keane   for (int i = 0; i < 10; ++i) {
49721558aeSErich Keane     // expected-error@+4{{expected '['}}
50721558aeSErich Keane     // expected-error@+3{{expected ')'}}
51721558aeSErich Keane     // expected-note@+2{{to match this '('}}
52721558aeSErich Keane     // expected-warning@+1{{OpenACC directives not yet implemented, pragma ignored}}
53721558aeSErich Keane     #pragma acc cache(ArrayPtr
54721558aeSErich Keane   }
55721558aeSErich Keane 
56721558aeSErich Keane   for (int i = 0; i < 10; ++i) {
57721558aeSErich Keane     // expected-error@+2{{use of undeclared identifier 'invalid'}}
58721558aeSErich Keane     // expected-warning@+1{{OpenACC directives not yet implemented, pragma ignored}}
59721558aeSErich Keane     #pragma acc cache(invalid)
60721558aeSErich Keane   }
61721558aeSErich Keane 
62721558aeSErich Keane   for (int i = 0; i < 10; ++i) {
63721558aeSErich Keane     // expected-error@+2{{expected '['}}
64721558aeSErich Keane     // expected-warning@+1{{OpenACC directives not yet implemented, pragma ignored}}
65721558aeSErich Keane     #pragma acc cache(ArrayPtr)
66721558aeSErich Keane   }
67721558aeSErich Keane 
68721558aeSErich Keane   for (int i = 0; i < 10; ++i) {
69721558aeSErich Keane     // expected-error@+4{{expected expression}}
70721558aeSErich Keane     // expected-error@+3{{expected ')'}}
71721558aeSErich Keane     // expected-note@+2{{to match this '('}}
72721558aeSErich Keane     // expected-warning@+1{{OpenACC directives not yet implemented, pragma ignored}}
73721558aeSErich Keane     #pragma acc cache(ArrayPtr[
74721558aeSErich Keane   }
75721558aeSErich Keane 
76721558aeSErich Keane   for (int i = 0; i < 10; ++i) {
77721558aeSErich Keane     // expected-error@+2{{expected expression}}
78721558aeSErich Keane     // expected-warning@+1{{OpenACC directives not yet implemented, pragma ignored}}
79721558aeSErich Keane     #pragma acc cache(ArrayPtr[, 5)
80721558aeSErich Keane   }
81721558aeSErich Keane 
82721558aeSErich Keane   for (int i = 0; i < 10; ++i) {
83721558aeSErich Keane     // expected-error@+2{{expected expression}}
84721558aeSErich Keane     // expected-warning@+1{{OpenACC directives not yet implemented, pragma ignored}}
85721558aeSErich Keane     #pragma acc cache(Array[)
86721558aeSErich Keane   }
87721558aeSErich Keane 
88721558aeSErich Keane   for (int i = 0; i < 10; ++i) {
89721558aeSErich Keane     // expected-warning@+1{{OpenACC directives not yet implemented, pragma ignored}}
90721558aeSErich Keane     #pragma acc cache(Array[*readonly])
91721558aeSErich Keane   }
92721558aeSErich Keane 
93721558aeSErich Keane   for (int i = 0; i < 10; ++i) {
94721558aeSErich Keane     // expected-error@+4{{expected expression}}
95721558aeSErich Keane     // expected-error@+3{{expected ')'}}
96721558aeSErich Keane     // expected-note@+2{{to match this '('}}
97721558aeSErich Keane     // expected-warning@+1{{OpenACC directives not yet implemented, pragma ignored}}
98721558aeSErich Keane     #pragma acc cache(Array[*readonly:
99721558aeSErich Keane   }
100721558aeSErich Keane 
101721558aeSErich Keane   for (int i = 0; i < 10; ++i) {
102721558aeSErich Keane     // expected-error@+2{{expected '['}}
103721558aeSErich Keane     // expected-warning@+1{{OpenACC directives not yet implemented, pragma ignored}}
104721558aeSErich Keane     #pragma acc cache(readonly)
105721558aeSErich Keane   }
106721558aeSErich Keane 
107721558aeSErich Keane   for (int i = 0; i < 10; ++i) {
108721558aeSErich Keane     // expected-error@+2{{expected '['}}
109721558aeSErich Keane     // expected-warning@+1{{OpenACC directives not yet implemented, pragma ignored}}
110721558aeSErich Keane     #pragma acc cache(readonly:ArrayPtr)
111721558aeSErich Keane   }
112721558aeSErich Keane 
113721558aeSErich Keane   for (int i = 0; i < 10; ++i) {
114721558aeSErich Keane     // expected-error@+2{{expected expression}}
115721558aeSErich Keane     // expected-warning@+1{{OpenACC directives not yet implemented, pragma ignored}}
116721558aeSErich Keane     #pragma acc cache(readonly:ArrayPtr[5:])
117721558aeSErich Keane   }
118721558aeSErich Keane 
119721558aeSErich Keane   for (int i = 0; i < 10; ++i) {
120721558aeSErich Keane     // expected-warning@+1{{OpenACC directives not yet implemented, pragma ignored}}
121721558aeSErich Keane     #pragma acc cache(readonly:ArrayPtr[5:*readonly])
122721558aeSErich Keane   }
123721558aeSErich Keane 
124721558aeSErich Keane   for (int i = 0; i < 10; ++i) {
125721558aeSErich Keane     // expected-error@+2{{expected '['}}
126721558aeSErich Keane     // expected-warning@+1{{OpenACC directives not yet implemented, pragma ignored}}
127721558aeSErich Keane     #pragma acc cache(readonly:ArrayPtr[5:*readonly], Array)
128721558aeSErich Keane   }
129721558aeSErich Keane 
130721558aeSErich Keane   for (int i = 0; i < 10; ++i) {
131721558aeSErich Keane     // expected-warning@+1{{OpenACC directives not yet implemented, pragma ignored}}
132721558aeSErich Keane     #pragma acc cache(readonly:ArrayPtr[5:*readonly], Array[*readonly:3])
133721558aeSErich Keane   }
134721558aeSErich Keane 
135721558aeSErich Keane   for (int i = 0; i < 10; ++i) {
136721558aeSErich Keane     // expected-warning@+1{{OpenACC directives not yet implemented, pragma ignored}}
137721558aeSErich Keane     #pragma acc cache(readonly:ArrayPtr[5 + i:*readonly], Array[*readonly + i:3])
138721558aeSErich Keane   }
139721558aeSErich Keane 
140721558aeSErich Keane   for (int i = 0; i < 10; ++i) {
141721558aeSErich Keane     // expected-error@+4{{expected identifier}}
142721558aeSErich Keane     // expected-error@+3{{expected ')'}}
143721558aeSErich Keane     // expected-note@+2{{to match this '('}}
144721558aeSErich Keane     // expected-warning@+1{{OpenACC directives not yet implemented, pragma ignored}}
145721558aeSErich Keane     #pragma acc cache(readonly:ArrayPtr[5:*readonly],
146721558aeSErich Keane   }
147721558aeSErich Keane 
148721558aeSErich Keane   for (int i = 0; i < 10; ++i) {
149721558aeSErich Keane     // expected-error@+2{{expected identifier}}
150721558aeSErich Keane     // expected-warning@+1{{OpenACC directives not yet implemented, pragma ignored}}
151721558aeSErich Keane     #pragma acc cache(readonly:ArrayPtr[5:*readonly],)
152721558aeSErich Keane   }
153721558aeSErich Keane 
154721558aeSErich Keane   for (int i = 0; i < 10; ++i) {
155721558aeSErich Keane     // expected-warning@+2{{left operand of comma operator has no effect}}
156721558aeSErich Keane     // expected-warning@+1{{OpenACC directives not yet implemented, pragma ignored}}
157721558aeSErich Keane     #pragma acc cache(readonly:ArrayPtr[5,6:*readonly])
158721558aeSErich Keane   }
159721558aeSErich Keane 
160721558aeSErich Keane   for (int i = 0; i < 10; ++i) {
161721558aeSErich Keane     // expected-warning@+2{{left operand of comma operator has no effect}}
162721558aeSErich Keane     // expected-warning@+1{{OpenACC directives not yet implemented, pragma ignored}}
163721558aeSErich Keane     #pragma acc cache(readonly:ArrayPtr[5:3, *readonly], ArrayPtr[0])
164721558aeSErich Keane   }
165721558aeSErich Keane 
166721558aeSErich Keane }
167