Skip to content

Commit bb8a7a7

Browse files
committed
[OpenACC] Implement 'pqr-list' has at least one 1 item.
OpenACC Github PR#499 defines the pqr-list as having at least 1 item. We already handle that for all but 'wait', so this patch just does the work to add it for 'wait', plus adds tests.
1 parent 2bee246 commit bb8a7a7

16 files changed

+493
-32
lines changed

clang/lib/Parse/ParseOpenACC.cpp

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1274,19 +1274,32 @@ Parser::ParseOpenACCWaitArgument(SourceLocation Loc, bool IsDirective) {
12741274
ConsumeToken();
12751275
}
12761276

1277+
1278+
12771279
// OpenACC 3.3, section 2.16:
12781280
// the term 'async-argument' means a nonnegative scalar integer expression, or
12791281
// one of the special values 'acc_async_noval' or 'acc_async_sync', as defined
12801282
// in the C header file and the Fortran opacc module.
1281-
bool FirstArg = true;
1283+
OpenACCIntExprParseResult Res = ParseOpenACCAsyncArgument(
1284+
IsDirective ? OpenACCDirectiveKind::Wait
1285+
: OpenACCDirectiveKind::Invalid,
1286+
IsDirective ? OpenACCClauseKind::Invalid : OpenACCClauseKind::Wait,
1287+
Loc);
1288+
1289+
if (Res.first.isInvalid() &&
1290+
Res.second == OpenACCParseCanContinue::Cannot) {
1291+
Result.Failed = true;
1292+
return Result;
1293+
}
1294+
1295+
if (Res.first.isUsable())
1296+
Result.QueueIdExprs.push_back(Res.first.get());
1297+
12821298
while (!getCurToken().isOneOf(tok::r_paren, tok::annot_pragma_openacc_end)) {
1283-
if (!FirstArg) {
1284-
if (ExpectAndConsume(tok::comma)) {
1285-
Result.Failed = true;
1286-
return Result;
1287-
}
1299+
if (ExpectAndConsume(tok::comma)) {
1300+
Result.Failed = true;
1301+
return Result;
12881302
}
1289-
FirstArg = false;
12901303

12911304
OpenACCIntExprParseResult Res = ParseOpenACCAsyncArgument(
12921305
IsDirective ? OpenACCDirectiveKind::Wait

clang/test/AST/ast-print-openacc-combined-construct.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,8 @@ void foo() {
139139
#pragma acc kernels loop deviceptr(iPtr, arrayPtr[0])
140140
for(int i = 0;i<5;++i);
141141

142-
// CHECK: #pragma acc parallel loop wait()
143-
#pragma acc parallel loop wait()
142+
// CHECK: #pragma acc parallel loop wait
143+
#pragma acc parallel loop wait
144144
for(int i = 0;i<5;++i);
145145

146146
// CHECK: #pragma acc parallel loop wait(*iPtr, i)

clang/test/AST/ast-print-openacc-compute-construct.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,8 @@ void foo() {
8888
#pragma acc parallel wait
8989
while(true);
9090

91-
// CHECK: #pragma acc parallel wait()
92-
#pragma acc parallel wait()
91+
// CHECK: #pragma acc parallel wait
92+
#pragma acc parallel wait
9393
while(true);
9494

9595
// CHECK: #pragma acc parallel wait(*iPtr, i)

clang/test/AST/ast-print-openacc-data-construct.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,11 @@ void foo() {
5050
#pragma acc exit data copyout(i) async
5151

5252
// CHECK: #pragma acc data default(none) wait
53-
#pragma acc data default(none) wait()
53+
#pragma acc data default(none) wait
5454
;
5555

56-
// CHECK: #pragma acc enter data copyin(Var) wait()
57-
#pragma acc enter data copyin(Var) wait()
56+
// CHECK: #pragma acc enter data copyin(Var) wait
57+
#pragma acc enter data copyin(Var) wait
5858

5959
// CHECK: #pragma acc exit data copyout(Var) wait(*iPtr, i)
6060
#pragma acc exit data copyout(Var) wait(*iPtr, i)

clang/test/AST/ast-print-openacc-wait-construct.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ void uses() {
55
int I;
66
float array[5];
77

8-
// CHECK: #pragma acc wait() if(I == array[I])
9-
#pragma acc wait() if(I == array[I])
8+
// CHECK: #pragma acc wait if(I == array[I])
9+
#pragma acc wait if(I == array[I])
1010

1111
// CHECK: #pragma acc wait(*iPtr, I) async
1212
#pragma acc wait(*iPtr, I) async

clang/test/ParserOpenACC/parse-wait-clause.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,17 @@ void func() {
1010
#pragma acc parallel wait clause-list
1111
{}
1212

13+
// expected-error@+3{{expected expression}}
1314
// expected-error@+2{{expected ')'}}
1415
// expected-note@+1{{to match this '('}}
1516
#pragma acc parallel wait (
1617
{}
1718

19+
// expected-error@+1{{expected expression}}
1820
#pragma acc parallel wait ()
1921
{}
2022

23+
// expected-error@+2{{expected expression}}
2124
// expected-error@+1{{invalid OpenACC clause 'clause'}}
2225
#pragma acc parallel wait () clause-list
2326
{}
@@ -52,26 +55,32 @@ void func() {
5255
#pragma acc parallel wait (devnum: i + j) clause-list
5356
{}
5457

58+
// expected-error@+3{{expected expression}}
5559
// expected-error@+2{{expected ')'}}
5660
// expected-note@+1{{to match this '('}}
5761
#pragma acc parallel wait (queues:
5862
{}
5963

64+
// expected-error@+1{{expected expression}}
6065
#pragma acc parallel wait (queues:)
6166
{}
6267

68+
// expected-error@+2{{expected expression}}
6369
// expected-error@+1{{invalid OpenACC clause 'clause'}}
6470
#pragma acc parallel wait (queues:) clause-list
6571
{}
6672

73+
// expected-error@+3{{expected expression}}
6774
// expected-error@+2{{expected ')'}}
6875
// expected-note@+1{{to match this '('}}
6976
#pragma acc parallel wait (devnum: i + j:queues:
7077
{}
7178

79+
// expected-error@+1{{expected expression}}
7280
#pragma acc parallel wait (devnum: i + j:queues:)
7381
{}
7482

83+
// expected-error@+2{{expected expression}}
7584
// expected-error@+1{{invalid OpenACC clause 'clause'}}
7685
#pragma acc parallel wait (devnum: i + j:queues:) clause-list
7786
{}

clang/test/ParserOpenACC/parse-wait-construct.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,15 @@ void func() {
88
// expected-error@+1{{invalid OpenACC clause 'clause'}}
99
#pragma acc wait clause-list
1010

11+
// expected-error@+3{{expected expression}}
1112
// expected-error@+2{{expected ')'}}
1213
// expected-note@+1{{to match this '('}}
1314
#pragma acc wait (
1415

16+
// expected-error@+1{{expected expression}}
1517
#pragma acc wait ()
1618

19+
// expected-error@+2{{expected expression}}
1720
// expected-error@+1{{invalid OpenACC clause 'clause'}}
1821
#pragma acc wait () clause-list
1922

@@ -41,21 +44,27 @@ void func() {
4144
// expected-error@+1{{invalid OpenACC clause 'clause'}}
4245
#pragma acc wait (devnum: i + j) clause-list
4346

47+
// expected-error@+3{{expected expression}}
4448
// expected-error@+2{{expected ')'}}
4549
// expected-note@+1{{to match this '('}}
4650
#pragma acc wait (queues:
4751

52+
// expected-error@+1{{expected expression}}
4853
#pragma acc wait (queues:)
4954

55+
// expected-error@+2{{expected expression}}
5056
// expected-error@+1{{invalid OpenACC clause 'clause'}}
5157
#pragma acc wait (queues:) clause-list
5258

59+
// expected-error@+3{{expected expression}}
5360
// expected-error@+2{{expected ')'}}
5461
// expected-note@+1{{to match this '('}}
5562
#pragma acc wait (devnum: i + j:queues:
5663

64+
// expected-error@+1{{expected expression}}
5765
#pragma acc wait (devnum: i + j:queues:)
5866

67+
// expected-error@+2{{expected expression}}
5968
// expected-error@+1{{invalid OpenACC clause 'clause'}}
6069
#pragma acc wait (devnum: i + j:queues:) clause-list
6170

clang/test/SemaOpenACC/combined-construct-wait-ast.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ void NormalUses() {
2020
// CHECK-NEXT: wait clause
2121
// CHECK-NEXT: <<<NULL>>>
2222
// CHECK-NEXT: ForStmt
23-
#pragma acc serial loop wait()
23+
#pragma acc serial loop wait
2424
for (int i = 0; i < 5; ++i) {}
2525
// CHECK: OpenACCCombinedConstruct{{.*}}serial loop
2626
// CHECK-NEXT: wait clause
@@ -105,7 +105,7 @@ void TemplUses(U u) {
105105
// CHECK-NEXT: <<<NULL>>>
106106
// CHECK-NEXT: ForStmt
107107

108-
#pragma acc serial loop wait()
108+
#pragma acc serial loop wait
109109
for (int i = 0; i < 5; ++i) {}
110110
// CHECK: OpenACCCombinedConstruct{{.*}}serial loop
111111
// CHECK-NEXT: wait clause

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

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,6 @@ void uses() {
1010
#pragma acc parallel loop wait
1111
for (unsigned i = 0; i < 5; ++i);
1212

13-
#pragma acc serial loop wait()
14-
for (unsigned i = 0; i < 5; ++i);
15-
1613
#pragma acc kernels loop wait(getS(), getI())
1714
for (unsigned i = 0; i < 5; ++i);
1815

clang/test/SemaOpenACC/compute-construct-intexpr-clause-ast.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ void NormalUses() {
144144
// CHECK-NEXT: WhileStmt
145145
// CHECK-NEXT: CXXBoolLiteralExpr
146146
// CHECK-NEXT: CompoundStmt
147-
#pragma acc parallel wait()
147+
#pragma acc parallel wait
148148
while (true){}
149149
// CHECK-NEXT: OpenACCComputeConstruct{{.*}}parallel
150150
// CHECK-NEXT: wait clause
@@ -378,7 +378,7 @@ void TemplUses(T t, U u) {
378378
// CHECK-NEXT: CXXBoolLiteralExpr
379379
// CHECK-NEXT: CompoundStmt
380380

381-
#pragma acc parallel wait()
381+
#pragma acc parallel wait
382382
while (true){}
383383
// CHECK-NEXT: OpenACCComputeConstruct{{.*}}parallel
384384
// CHECK-NEXT: wait clause

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

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,6 @@ void uses() {
1010
#pragma acc parallel wait
1111
while(1);
1212

13-
#pragma acc serial wait()
14-
while(1);
15-
1613
#pragma acc kernels wait(getS(), getI())
1714
while(1);
1815

clang/test/SemaOpenACC/data-construct-wait-ast.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ void NormalUses() {
2626
// CHECK-NEXT: wait clause
2727
// CHECK-NEXT: <<<NULL>>>
2828
// CHECK-NEXT: NullStmt
29-
#pragma acc enter data copyin(I) wait()
29+
#pragma acc enter data copyin(I) wait
3030
// CHECK: OpenACCEnterDataConstruct{{.*}}enter data
3131
// CHECK-NEXT: copyin clause
3232
// CHECK-NEXT: DeclRefExpr{{.*}}'I' 'int'
@@ -119,7 +119,7 @@ void TemplUses(U u) {
119119
// CHECK-NEXT: <<<NULL>>>
120120
// CHECK-NEXT: NullStmt
121121

122-
#pragma acc enter data copyin(I) wait()
122+
#pragma acc enter data copyin(I) wait
123123
// CHECK: OpenACCEnterDataConstruct{{.*}}enter data
124124
// CHECK-NEXT: copyin clause
125125
// CHECK-NEXT: DeclRefExpr{{.*}}'I' 'U'

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ void uses() {
1010
#pragma acc data copyin(arr[0]) wait
1111
;
1212

13-
#pragma acc enter data copyin(arr[0]) wait()
13+
#pragma acc enter data copyin(arr[0]) wait
1414

1515
#pragma acc exit data copyout(arr[0]) wait(getS(), getI())
1616

0 commit comments

Comments
 (0)