Skip to content

Commit 6119340

Browse files
committed
[OpenACC] Audit/add tests to ensure we enforce appertainment correctly
I apparently missed a few other clauses as well when doing my initial implementation, so this adds tests for all, and fixes up the few that had problems. This is something that I'll do better to keep an eye on, though shouldn't be necessary once the rest of the clauses are implemented and we can remove the 'default' case.
1 parent 5849cba commit 6119340

20 files changed

+178
-0
lines changed

clang/lib/Sema/SemaOpenACC.cpp

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,57 @@ bool doesClauseApplyToDirective(OpenACCDirectiveKind DirectiveKind,
170170
default:
171171
return false;
172172
}
173+
case OpenACCClauseKind::CopyIn:
174+
case OpenACCClauseKind::PCopyIn:
175+
case OpenACCClauseKind::PresentOrCopyIn:
176+
switch (DirectiveKind) {
177+
case OpenACCDirectiveKind::Parallel:
178+
case OpenACCDirectiveKind::Serial:
179+
case OpenACCDirectiveKind::Kernels:
180+
case OpenACCDirectiveKind::Data:
181+
case OpenACCDirectiveKind::EnterData:
182+
case OpenACCDirectiveKind::Declare:
183+
case OpenACCDirectiveKind::ParallelLoop:
184+
case OpenACCDirectiveKind::SerialLoop:
185+
case OpenACCDirectiveKind::KernelsLoop:
186+
return true;
187+
default:
188+
return false;
189+
}
190+
case OpenACCClauseKind::CopyOut:
191+
case OpenACCClauseKind::PCopyOut:
192+
case OpenACCClauseKind::PresentOrCopyOut:
193+
switch (DirectiveKind) {
194+
case OpenACCDirectiveKind::Parallel:
195+
case OpenACCDirectiveKind::Serial:
196+
case OpenACCDirectiveKind::Kernels:
197+
case OpenACCDirectiveKind::Data:
198+
case OpenACCDirectiveKind::ExitData:
199+
case OpenACCDirectiveKind::Declare:
200+
case OpenACCDirectiveKind::ParallelLoop:
201+
case OpenACCDirectiveKind::SerialLoop:
202+
case OpenACCDirectiveKind::KernelsLoop:
203+
return true;
204+
default:
205+
return false;
206+
}
207+
case OpenACCClauseKind::Create:
208+
case OpenACCClauseKind::PCreate:
209+
case OpenACCClauseKind::PresentOrCreate:
210+
switch (DirectiveKind) {
211+
case OpenACCDirectiveKind::Parallel:
212+
case OpenACCDirectiveKind::Serial:
213+
case OpenACCDirectiveKind::Kernels:
214+
case OpenACCDirectiveKind::Data:
215+
case OpenACCDirectiveKind::EnterData:
216+
case OpenACCDirectiveKind::ParallelLoop:
217+
case OpenACCDirectiveKind::SerialLoop:
218+
case OpenACCDirectiveKind::KernelsLoop:
219+
return true;
220+
default:
221+
return false;
222+
}
223+
173224
case OpenACCClauseKind::Attach:
174225
switch (DirectiveKind) {
175226
case OpenACCDirectiveKind::Parallel:

clang/test/SemaOpenACC/compute-construct-async-clause.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,9 @@ void Test() {
3838

3939
#pragma acc kernels async(SomeE)
4040
while(1);
41+
42+
// expected-error@+2{{OpenACC 'async' clause is not valid on 'loop' directive}}
43+
// expected-warning@+1{{OpenACC construct 'loop' not yet implemented}}
44+
#pragma acc loop async(1)
45+
for(;;);
4146
}

clang/test/SemaOpenACC/compute-construct-attach-clause.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,4 +58,9 @@ void uses() {
5858

5959
#pragma acc parallel attach(s.PtrMem)
6060
while (1);
61+
62+
// expected-error@+2{{OpenACC 'attach' clause is not valid on 'loop' directive}}
63+
// expected-warning@+1{{OpenACC construct 'loop' not yet implemented}}
64+
#pragma acc loop attach(LocalInt)
65+
for(;;);
6166
}

clang/test/SemaOpenACC/compute-construct-copy-clause.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,4 +59,17 @@ void uses(int IntParam, short *PointerParam, float ArrayParam[5], Complete Compo
5959
// expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}}
6060
#pragma acc parallel copy((float)ArrayParam[2])
6161
while(1);
62+
63+
// expected-error@+2{{OpenACC 'copy' clause is not valid on 'loop' directive}}
64+
// expected-warning@+1{{OpenACC construct 'loop' not yet implemented}}
65+
#pragma acc loop copy(LocalInt)
66+
for(;;);
67+
// expected-error@+2{{OpenACC 'pcopy' clause is not valid on 'loop' directive}}
68+
// expected-warning@+1{{OpenACC construct 'loop' not yet implemented}}
69+
#pragma acc loop pcopy(LocalInt)
70+
for(;;);
71+
// expected-error@+2{{OpenACC 'present_or_copy' clause is not valid on 'loop' directive}}
72+
// expected-warning@+1{{OpenACC construct 'loop' not yet implemented}}
73+
#pragma acc loop present_or_copy(LocalInt)
74+
for(;;);
6275
}

clang/test/SemaOpenACC/compute-construct-copyin-clause.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,4 +65,17 @@ void uses(int IntParam, short *PointerParam, float ArrayParam[5], Complete Compo
6565
// expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}}
6666
#pragma acc parallel copyin(invalid:(float)ArrayParam[2])
6767
while(1);
68+
69+
// expected-error@+2{{OpenACC 'copyin' clause is not valid on 'loop' directive}}
70+
// expected-warning@+1{{OpenACC construct 'loop' not yet implemented}}
71+
#pragma acc loop copyin(LocalInt)
72+
for(;;);
73+
// expected-error@+2{{OpenACC 'pcopyin' clause is not valid on 'loop' directive}}
74+
// expected-warning@+1{{OpenACC construct 'loop' not yet implemented}}
75+
#pragma acc loop pcopyin(LocalInt)
76+
for(;;);
77+
// expected-error@+2{{OpenACC 'present_or_copyin' clause is not valid on 'loop' directive}}
78+
// expected-warning@+1{{OpenACC construct 'loop' not yet implemented}}
79+
#pragma acc loop present_or_copyin(LocalInt)
80+
for(;;);
6881
}

clang/test/SemaOpenACC/compute-construct-copyout-clause.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,4 +65,17 @@ void uses(int IntParam, short *PointerParam, float ArrayParam[5], Complete Compo
6565
// expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}}
6666
#pragma acc parallel copyout(invalid:(float)ArrayParam[2])
6767
while(1);
68+
69+
// expected-error@+2{{OpenACC 'copyout' clause is not valid on 'loop' directive}}
70+
// expected-warning@+1{{OpenACC construct 'loop' not yet implemented}}
71+
#pragma acc loop copyout(LocalInt)
72+
for(;;);
73+
// expected-error@+2{{OpenACC 'pcopyout' clause is not valid on 'loop' directive}}
74+
// expected-warning@+1{{OpenACC construct 'loop' not yet implemented}}
75+
#pragma acc loop pcopyout(LocalInt)
76+
for(;;);
77+
// expected-error@+2{{OpenACC 'present_or_copyout' clause is not valid on 'loop' directive}}
78+
// expected-warning@+1{{OpenACC construct 'loop' not yet implemented}}
79+
#pragma acc loop present_or_copyout(LocalInt)
80+
for(;;);
6881
}

clang/test/SemaOpenACC/compute-construct-create-clause.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,4 +66,17 @@ void uses(int IntParam, short *PointerParam, float ArrayParam[5], Complete Compo
6666
// expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}}
6767
#pragma acc parallel create(invalid:(float)ArrayParam[2])
6868
while(1);
69+
70+
// expected-error@+2{{OpenACC 'create' clause is not valid on 'loop' directive}}
71+
// expected-warning@+1{{OpenACC construct 'loop' not yet implemented}}
72+
#pragma acc loop create(LocalInt)
73+
for(;;);
74+
// expected-error@+2{{OpenACC 'pcreate' clause is not valid on 'loop' directive}}
75+
// expected-warning@+1{{OpenACC construct 'loop' not yet implemented}}
76+
#pragma acc loop pcreate(LocalInt)
77+
for(;;);
78+
// expected-error@+2{{OpenACC 'present_or_create' clause is not valid on 'loop' directive}}
79+
// expected-warning@+1{{OpenACC construct 'loop' not yet implemented}}
80+
#pragma acc loop present_or_create(LocalInt)
81+
for(;;);
6982
}

clang/test/SemaOpenACC/compute-construct-default-clause.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,4 +52,9 @@ void SingleOnly() {
5252
// expected-error@+1{{OpenACC 'default' clause is not valid on 'wait' directive}}
5353
#pragma acc wait default(none)
5454
while(0);
55+
56+
// expected-error@+2{{OpenACC 'default' clause is not valid on 'loop' directive}}
57+
// expected-warning@+1{{OpenACC construct 'loop' not yet implemented}}
58+
#pragma acc loop default(present)
59+
for(;;);
5560
}

clang/test/SemaOpenACC/compute-construct-deviceptr-clause.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,4 +58,9 @@ void uses() {
5858

5959
#pragma acc parallel deviceptr(s.PtrMem)
6060
while (1);
61+
62+
// expected-error@+2{{OpenACC 'deviceptr' clause is not valid on 'loop' directive}}
63+
// expected-warning@+1{{OpenACC construct 'loop' not yet implemented}}
64+
#pragma acc loop deviceptr(LocalInt)
65+
for(;;);
6166
}

clang/test/SemaOpenACC/compute-construct-firstprivate-clause.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,4 +52,9 @@ void uses(int IntParam, short *PointerParam, float ArrayParam[5], Complete Compo
5252
// expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}}
5353
#pragma acc parallel firstprivate((float)ArrayParam[2])
5454
while(1);
55+
56+
// expected-error@+2{{OpenACC 'firstprivate' clause is not valid on 'loop' directive}}
57+
// expected-warning@+1{{OpenACC construct 'loop' not yet implemented}}
58+
#pragma acc loop firstprivate(LocalInt)
59+
for(;;);
5560
}

clang/test/SemaOpenACC/compute-construct-if-clause.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,4 +59,9 @@ void BoolExpr(int *I, float *F) {
5959
// expected-warning@+1{{OpenACC clause 'if' not yet implemented}}
6060
#pragma acc kernels loop if (*I < *F)
6161
while(0);
62+
63+
// expected-error@+2{{OpenACC 'if' clause is not valid on 'loop' directive}}
64+
// expected-warning@+1{{OpenACC construct 'loop' not yet implemented}}
65+
#pragma acc loop if(I)
66+
for(;;);
6267
}

clang/test/SemaOpenACC/compute-construct-no_create-clause.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,4 +51,9 @@ void uses(int IntParam, short *PointerParam, float ArrayParam[5], Complete Compo
5151
// expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}}
5252
#pragma acc parallel no_create((float)ArrayParam[2])
5353
while(1);
54+
55+
// expected-error@+2{{OpenACC 'no_create' clause is not valid on 'loop' directive}}
56+
// expected-warning@+1{{OpenACC construct 'loop' not yet implemented}}
57+
#pragma acc loop no_create(LocalInt)
58+
for(;;);
5459
}

clang/test/SemaOpenACC/compute-construct-num_gangs-clause.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,4 +51,9 @@ void Test() {
5151
// expected-error@+1{{too many integer expression arguments provided to OpenACC 'num_gangs' clause: 'parallel' directive expects maximum of 3, 4 were provided}}
5252
#pragma acc parallel num_gangs(getS(), 1, getS(), 1)
5353
while(1);
54+
55+
// expected-error@+2{{OpenACC 'num_gangs' clause is not valid on 'loop' directive}}
56+
// expected-warning@+1{{OpenACC construct 'loop' not yet implemented}}
57+
#pragma acc loop num_gangs(1)
58+
for(;;);
5459
}

clang/test/SemaOpenACC/compute-construct-num_workers-clause.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,9 @@ void Test() {
3030

3131
#pragma acc kernels num_workers(SomeE)
3232
while(1);
33+
34+
// expected-error@+2{{OpenACC 'num_workers' clause is not valid on 'loop' directive}}
35+
// expected-warning@+1{{OpenACC construct 'loop' not yet implemented}}
36+
#pragma acc loop num_workers(1)
37+
for(;;);
3338
}

clang/test/SemaOpenACC/compute-construct-present-clause.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,4 +51,9 @@ void uses(int IntParam, short *PointerParam, float ArrayParam[5], Complete Compo
5151
// expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}}
5252
#pragma acc parallel present((float)ArrayParam[2])
5353
while(1);
54+
55+
// expected-error@+2{{OpenACC 'present' clause is not valid on 'loop' directive}}
56+
// expected-warning@+1{{OpenACC construct 'loop' not yet implemented}}
57+
#pragma acc loop present(LocalInt)
58+
for(;;);
5459
}

clang/test/SemaOpenACC/compute-construct-private-clause.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,4 +134,9 @@ void uses(int IntParam, short *PointerParam, float ArrayParam[5], Complete Compo
134134
// expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}}
135135
#pragma acc parallel private((float)ArrayParam[2])
136136
while(1);
137+
138+
// expected-error@+2{{OpenACC 'private' clause is not valid on 'init' directive}}
139+
// expected-warning@+1{{OpenACC construct 'init' not yet implemented}}
140+
#pragma acc init private(LocalInt)
141+
for(;;);
137142
}

clang/test/SemaOpenACC/compute-construct-reduction-clause.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,4 +104,9 @@ void uses(unsigned Parm) {
104104
// expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, or composite variable member}}
105105
#pragma acc parallel reduction(&:HA.array[1:2])
106106
while (1);
107+
108+
// expected-error@+2{{OpenACC 'reduction' clause is not valid on 'init' directive}}
109+
// expected-warning@+1{{OpenACC construct 'init' not yet implemented}}
110+
#pragma acc init reduction(+:I)
111+
for(;;);
107112
}

clang/test/SemaOpenACC/compute-construct-self-clause.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,4 +79,9 @@ void WarnMaybeNotUsed(int val1, int val2) {
7979
// expected-error@+1{{use of undeclared identifier 'invalid'}}
8080
#pragma acc parallel if(invalid) self(val1)
8181
while(0);
82+
83+
// expected-error@+2{{OpenACC 'self' clause is not valid on 'loop' directive}}
84+
// expected-warning@+1{{OpenACC construct 'loop' not yet implemented}}
85+
#pragma acc loop self
86+
for(;;);
8287
}

clang/test/SemaOpenACC/compute-construct-vector_length-clause.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,9 @@ void Test() {
3030

3131
#pragma acc kernels vector_length(SomeE)
3232
while(1);
33+
34+
// expected-error@+2{{OpenACC 'vector_length' clause is not valid on 'loop' directive}}
35+
// expected-warning@+1{{OpenACC construct 'loop' not yet implemented}}
36+
#pragma acc loop vector_length(1)
37+
for(;;);
3338
}

clang/test/SemaOpenACC/compute-construct-wait-clause.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,9 @@ void uses() {
3535
// expected-error@+1{{OpenACC clause 'wait' requires expression of integer type ('struct NotConvertible' invalid)}}
3636
#pragma acc parallel wait(devnum:arr : queues: arr, NC, 5)
3737
while(1);
38+
39+
// expected-error@+2{{OpenACC 'wait' clause is not valid on 'loop' directive}}
40+
// expected-warning@+1{{OpenACC construct 'loop' not yet implemented}}
41+
#pragma acc loop wait
42+
for(;;);
3843
}

0 commit comments

Comments
 (0)