xref: /llvm-project/clang/test/ParserOpenACC/parse-cache-construct.cpp (revision c1298878175f1f6b7f991a18550de97a699cf260)
1721558aeSErich Keane // RUN: %clang_cc1 %s -verify -fopenacc
2721558aeSErich Keane 
3721558aeSErich Keane namespace NS {
4721558aeSErich Keane   static char* NSArray;// expected-note{{declared here}}
5721558aeSErich Keane   static int NSInt;// expected-note 2{{declared here}}
6721558aeSErich Keane }
7721558aeSErich Keane char *getArrayPtr();
8721558aeSErich Keane template<typename T, int I>
func()9721558aeSErich Keane void func() {
10721558aeSErich Keane   char *ArrayPtr = getArrayPtr();
11721558aeSErich Keane   for (int i = 0; i < 10; ++i) {
12db4ea21dSerichkeane     // expected-warning@+1{{OpenACC construct 'cache' not yet implemented, pragma ignored}}
13721558aeSErich Keane     #pragma acc cache(ArrayPtr[T::value + I:I + 5], T::array[(i + T::value, 5): 6])
14721558aeSErich Keane   }
15721558aeSErich Keane   for (int i = 0; i < 10; ++i) {
16db4ea21dSerichkeane     // expected-warning@+1{{OpenACC construct 'cache' not yet implemented, pragma ignored}}
17721558aeSErich Keane     #pragma acc cache(NS::NSArray[NS::NSInt])
18721558aeSErich Keane   }
19721558aeSErich Keane 
20721558aeSErich Keane   for (int i = 0; i < 10; ++i) {
21db4ea21dSerichkeane     // expected-warning@+1{{OpenACC construct 'cache' not yet implemented, pragma ignored}}
22721558aeSErich Keane     #pragma acc cache(NS::NSArray[NS::NSInt : NS::NSInt])
23721558aeSErich Keane   }
24721558aeSErich Keane 
25721558aeSErich Keane   for (int i = 0; i < 10; ++i) {
26721558aeSErich Keane     // expected-error@+2{{use of undeclared identifier 'NSArray'; did you mean 'NS::NSArray'}}
27db4ea21dSerichkeane     // expected-warning@+1{{OpenACC construct 'cache' not yet implemented, pragma ignored}}
28721558aeSErich Keane     #pragma acc cache(NSArray[NS::NSInt : NS::NSInt])
29721558aeSErich Keane   }
30721558aeSErich Keane 
31721558aeSErich Keane   for (int i = 0; i < 10; ++i) {
32721558aeSErich Keane     // expected-error@+2{{use of undeclared identifier 'NSInt'; did you mean 'NS::NSInt'}}
33db4ea21dSerichkeane     // expected-warning@+1{{OpenACC construct 'cache' not yet implemented, pragma ignored}}
34721558aeSErich Keane     #pragma acc cache(NS::NSArray[NSInt : NS::NSInt])
35721558aeSErich Keane   }
36721558aeSErich Keane 
37721558aeSErich Keane   for (int i = 0; i < 10; ++i) {
38721558aeSErich Keane     // expected-error@+2{{use of undeclared identifier 'NSInt'; did you mean 'NS::NSInt'}}
39db4ea21dSerichkeane     // expected-warning@+1{{OpenACC construct 'cache' not yet implemented, pragma ignored}}
40721558aeSErich Keane     #pragma acc cache(NS::NSArray[NS::NSInt : NSInt])
41721558aeSErich Keane   }
42721558aeSErich Keane }
43721558aeSErich Keane 
44721558aeSErich Keane struct S {
45721558aeSErich Keane   static constexpr int value = 5;
46721558aeSErich Keane   static constexpr char array[] ={1,2,3,4,5};
47721558aeSErich Keane };
48721558aeSErich Keane 
49cac6b1a5SErich Keane struct Members {
50cac6b1a5SErich Keane   int value = 5;
51cac6b1a5SErich Keane   char array[5] ={1,2,3,4,5};
52cac6b1a5SErich Keane };
53cac6b1a5SErich Keane struct HasMembersArray {
54cac6b1a5SErich Keane   Members MemArr[4];
55cac6b1a5SErich Keane };
56cac6b1a5SErich Keane 
57cac6b1a5SErich Keane 
use()58721558aeSErich Keane void use() {
59cac6b1a5SErich Keane 
60cac6b1a5SErich Keane   Members s;
61cac6b1a5SErich Keane   for (int i = 0; i < 10; ++i) {
62db4ea21dSerichkeane     // expected-warning@+1{{OpenACC construct 'cache' not yet implemented, pragma ignored}}
63cac6b1a5SErich Keane     #pragma acc cache(s.array[s.value])
64cac6b1a5SErich Keane   }
65cac6b1a5SErich Keane   HasMembersArray Arrs;
66cac6b1a5SErich Keane   for (int i = 0; i < 10; ++i) {
67db4ea21dSerichkeane     // expected-warning@+1{{OpenACC construct 'cache' not yet implemented, pragma ignored}}
68cac6b1a5SErich Keane     #pragma acc cache(Arrs.MemArr[3].array[4])
69cac6b1a5SErich Keane   }
70cac6b1a5SErich Keane   for (int i = 0; i < 10; ++i) {
71db4ea21dSerichkeane     // expected-warning@+1{{OpenACC construct 'cache' not yet implemented, pragma ignored}}
72cac6b1a5SErich Keane     #pragma acc cache(Arrs.MemArr[3].array[1:4])
73cac6b1a5SErich Keane   }
74cac6b1a5SErich Keane   for (int i = 0; i < 10; ++i) {
7539adc8f4SErich Keane     // expected-error@+2{{OpenACC sub-array is not allowed here}}
76db4ea21dSerichkeane     // expected-warning@+1{{OpenACC construct 'cache' not yet implemented, pragma ignored}}
77*c1298878SErich Keane     #pragma acc cache(Arrs.MemArr[2:1].array[1:4])
78cac6b1a5SErich Keane   }
79cac6b1a5SErich Keane   for (int i = 0; i < 10; ++i) {
8039adc8f4SErich Keane     // expected-error@+2{{OpenACC sub-array is not allowed here}}
81db4ea21dSerichkeane     // expected-warning@+1{{OpenACC construct 'cache' not yet implemented, pragma ignored}}
82*c1298878SErich Keane     #pragma acc cache(Arrs.MemArr[2:1].array[4])
83cac6b1a5SErich Keane   }
84cac6b1a5SErich Keane   for (int i = 0; i < 10; ++i) {
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}}
88cac6b1a5SErich Keane     #pragma acc cache(Arrs.MemArr[3:4:].array[4])
89cac6b1a5SErich Keane   }
90cac6b1a5SErich Keane   for (int i = 0; i < 10; ++i) {
91*c1298878SErich Keane     // expected-error@+2{{OpenACC sub-array is not allowed here}}
92db4ea21dSerichkeane     // expected-warning@+1{{OpenACC construct 'cache' not yet implemented, pragma ignored}}
93cac6b1a5SErich Keane     #pragma acc cache(Arrs.MemArr[:].array[4])
94cac6b1a5SErich Keane   }
95cac6b1a5SErich Keane   for (int i = 0; i < 10; ++i) {
96cac6b1a5SErich Keane     // expected-error@+2{{expected unqualified-id}}
97db4ea21dSerichkeane     // expected-warning@+1{{OpenACC construct 'cache' not yet implemented, pragma ignored}}
98cac6b1a5SErich Keane     #pragma acc cache(Arrs.MemArr[::].array[4])
99cac6b1a5SErich Keane   }
100cac6b1a5SErich Keane   for (int i = 0; i < 10; ++i) {
101cac6b1a5SErich Keane     // expected-error@+4{{expected expression}}
102cac6b1a5SErich Keane     // expected-error@+3{{expected ']'}}
103cac6b1a5SErich Keane     // expected-note@+2{{to match this '['}}
104db4ea21dSerichkeane     // expected-warning@+1{{OpenACC construct 'cache' not yet implemented, pragma ignored}}
105cac6b1a5SErich Keane     #pragma acc cache(Arrs.MemArr[: :].array[4])
106cac6b1a5SErich Keane   }
107cac6b1a5SErich Keane   for (int i = 0; i < 10; ++i) {
108*c1298878SErich Keane     // expected-error@+2{{OpenACC sub-array is not allowed here}}
109db4ea21dSerichkeane     // expected-warning@+1{{OpenACC construct 'cache' not yet implemented, pragma ignored}}
110cac6b1a5SErich Keane     #pragma acc cache(Arrs.MemArr[3:].array[4])
111cac6b1a5SErich Keane   }
112721558aeSErich Keane   func<S, 5>();
113721558aeSErich Keane }
114cac6b1a5SErich Keane 
115