[libc++] Refactor the sequence container benchmarks (#119763)
[llvm-project.git] / clang / test / SemaOpenACC / data-construct.cpp
blob4c868b68e332e4317ce5395a361ecb8c90d1f392
1 // RUN: %clang_cc1 %s -fopenacc -verify -Wno-empty-body -Wno-unused-value
3 void HasStmt() {
5 // expected-error@+2{{expected statement}}
6 #pragma acc data default(none)
9 int I;
11 // expected-error@+2{{expected statement}}
12 #pragma acc host_data use_device(I)
14 // Don't have statements, so this is fine.
16 #pragma acc enter data copyin(I)
19 #pragma acc exit data copyout(I)
23 void AtLeastOneOf() {
24 int Var;
25 int *VarPtr = &Var;
26 // Data
27 #pragma acc data copy(Var)
29 #pragma acc data copyin(Var)
31 #pragma acc data copyout(Var)
33 #pragma acc data create(Var)
35 #pragma acc data no_create(Var)
37 #pragma acc data present(Var)
39 #pragma acc data deviceptr(VarPtr)
41 #pragma acc data attach(VarPtr)
43 #pragma acc data default(none)
46 // expected-error@+1{{OpenACC 'data' construct must have at least one 'copy', 'copyin', 'copyout', 'create', 'no_create', 'present', 'deviceptr', 'attach' or 'default' clause}}
47 #pragma acc data if(Var)
50 // expected-error@+1{{OpenACC 'data' construct must have at least one 'copy', 'copyin', 'copyout', 'create', 'no_create', 'present', 'deviceptr', 'attach' or 'default' clause}}
51 #pragma acc data async
54 // expected-error@+1{{OpenACC 'data' construct must have at least one 'copy', 'copyin', 'copyout', 'create', 'no_create', 'present', 'deviceptr', 'attach' or 'default' clause}}
55 #pragma acc data wait
58 // expected-error@+1{{OpenACC 'data' construct must have at least one 'copy', 'copyin', 'copyout', 'create', 'no_create', 'present', 'deviceptr', 'attach' or 'default' clause}}
59 #pragma acc data device_type(*)
61 // expected-error@+1{{OpenACC 'data' construct must have at least one 'copy', 'copyin', 'copyout', 'create', 'no_create', 'present', 'deviceptr', 'attach' or 'default' clause}}
62 #pragma acc data
65 // Enter Data
66 #pragma acc enter data copyin(Var)
67 #pragma acc enter data create(Var)
68 #pragma acc enter data attach(VarPtr)
70 // expected-error@+1{{OpenACC 'enter data' construct must have at least one 'copyin', 'create' or 'attach' clause}}
71 #pragma acc enter data if(Var)
72 // expected-error@+1{{OpenACC 'enter data' construct must have at least one 'copyin', 'create' or 'attach' clause}}
73 #pragma acc enter data async
74 // expected-error@+1{{OpenACC 'enter data' construct must have at least one 'copyin', 'create' or 'attach' clause}}
75 #pragma acc enter data wait
76 // expected-error@+1{{OpenACC 'enter data' construct must have at least one 'copyin', 'create' or 'attach' clause}}
77 #pragma acc enter data
79 // Exit Data
80 #pragma acc exit data copyout(Var)
81 #pragma acc exit data delete(Var)
82 #pragma acc exit data detach(VarPtr)
84 // expected-error@+1{{OpenACC 'exit data' construct must have at least one 'copyout', 'delete' or 'detach' clause}}
85 #pragma acc exit data if(Var)
86 // expected-error@+1{{OpenACC 'exit data' construct must have at least one 'copyout', 'delete' or 'detach' clause}}
87 #pragma acc exit data async
88 // expected-error@+1{{OpenACC 'exit data' construct must have at least one 'copyout', 'delete' or 'detach' clause}}
89 #pragma acc exit data wait
90 // expected-error@+1{{OpenACC 'exit data' construct must have at least one 'copyout', 'delete' or 'detach' clause}}
91 #pragma acc exit data finalize
92 // expected-error@+1{{OpenACC 'exit data' construct must have at least one 'copyout', 'delete' or 'detach' clause}}
93 #pragma acc exit data
95 // Host Data
96 #pragma acc host_data use_device(Var)
99 // expected-error@+1{{OpenACC 'host_data' construct must have at least one 'use_device' clause}}
100 #pragma acc host_data if(Var)
102 // expected-error@+1{{OpenACC 'host_data' construct must have at least one 'use_device' clause}}
103 #pragma acc host_data if_present
105 // expected-error@+1{{OpenACC 'host_data' construct must have at least one 'use_device' clause}}
106 #pragma acc host_data
110 void DataRules() {
111 int Var;
112 // expected-error@+2{{OpenACC clause 'copy' may not follow a 'device_type' clause in a 'data' construct}}
113 // expected-note@+1{{previous clause is here}}
114 #pragma acc data default(none) device_type(*) copy(Var)
116 // expected-error@+2{{OpenACC clause 'copyin' may not follow a 'device_type' clause in a 'data' construct}}
117 // expected-note@+1{{previous clause is here}}
118 #pragma acc data default(none) device_type(*) copyin(Var)
120 // expected-error@+2{{OpenACC clause 'copyout' may not follow a 'device_type' clause in a 'data' construct}}
121 // expected-note@+1{{previous clause is here}}
122 #pragma acc data default(none) device_type(*) copyout(Var)
124 // expected-error@+2{{OpenACC clause 'create' may not follow a 'device_type' clause in a 'data' construct}}
125 // expected-note@+1{{previous clause is here}}
126 #pragma acc data default(none) device_type(*) create(Var)
128 // expected-error@+2{{OpenACC clause 'no_create' may not follow a 'device_type' clause in a 'data' construct}}
129 // expected-note@+1{{previous clause is here}}
130 #pragma acc data default(none) device_type(*) no_create(Var)
132 // expected-error@+2{{OpenACC clause 'present' may not follow a 'device_type' clause in a 'data' construct}}
133 // expected-note@+1{{previous clause is here}}
134 #pragma acc data default(none) device_type(*) present(Var)
136 // expected-error@+2{{OpenACC clause 'deviceptr' may not follow a 'device_type' clause in a 'data' construct}}
137 // expected-note@+1{{previous clause is here}}
138 #pragma acc data default(none) device_type(*) deviceptr(Var)
140 // expected-error@+2{{OpenACC clause 'attach' may not follow a 'device_type' clause in a 'data' construct}}
141 // expected-note@+1{{previous clause is here}}
142 #pragma acc data default(none) device_type(*) attach(Var)
144 // expected-error@+2{{OpenACC clause 'default' may not follow a 'device_type' clause in a 'data' construct}}
145 // expected-note@+1{{previous clause is here}}
146 #pragma acc data default(none) device_type(*) default(none)
148 // expected-error@+2{{OpenACC clause 'if' may not follow a 'device_type' clause in a 'data' construct}}
149 // expected-note@+1{{previous clause is here}}
150 #pragma acc data default(none) device_type(*) if(Var)
152 #pragma acc data default(none) device_type(*) async
154 #pragma acc data default(none) device_type(*) wait
158 struct HasMembers {
159 int Member;
161 void HostDataError() {
162 // expected-error@+1{{OpenACC variable in 'use_device' clause is not a valid variable name or array name}}
163 #pragma acc host_data use_device(this)
165 // expected-error@+1{{OpenACC variable in 'use_device' clause is not a valid variable name or array name}}
166 #pragma acc host_data use_device(this->Member)
168 // expected-error@+1{{OpenACC variable in 'use_device' clause is not a valid variable name or array name}}
169 #pragma acc host_data use_device(Member)
174 void HostDataRules() {
175 int Var, Var2;
176 // expected-error@+3{{OpenACC 'host_data' construct must have at least one 'use_device' clause}}
177 // expected-error@+2{{OpenACC 'if' clause cannot appear more than once on a 'host_data' directive}}
178 // expected-note@+1{{previous clause is here}}
179 #pragma acc host_data if(Var) if (Var2)
182 #pragma acc host_data use_device(Var)
185 int Array[5];
186 #pragma acc host_data use_device(Array)
189 // expected-error@+1{{OpenACC variable in 'use_device' clause is not a valid variable name or array name}}
190 #pragma acc host_data use_device(Array[1:1])
193 // expected-error@+1{{OpenACC variable in 'use_device' clause is not a valid variable name or array name}}
194 #pragma acc host_data use_device(Array[1])
196 HasMembers HM;
197 // expected-error@+1{{OpenACC variable in 'use_device' clause is not a valid variable name or array name}}
198 #pragma acc host_data use_device(HM.Member)