Skip to content

Commit 93b0229

Browse files
committed
[OpenACC] fix 'loop' restriction of auto/seq/independent
We previously allowed duplicates of auto/seq/independent on a 'loop' construct. This is disallowed by the restriction (which says exactly one of...), so this patch ensures they are disallowed.
1 parent 3158525 commit 93b0229

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

clang/lib/Sema/SemaOpenACCClause.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1264,7 +1264,8 @@ OpenACCClause *SemaOpenACCClauseVisitor::VisitAutoClause(
12641264
// Only one of the seq, independent, and auto clauses may appear.
12651265
const auto *Itr =
12661266
llvm::find_if(ExistingClauses,
1267-
llvm::IsaPred<OpenACCIndependentClause, OpenACCSeqClause>);
1267+
llvm::IsaPred<OpenACCAutoClause, OpenACCIndependentClause,
1268+
OpenACCSeqClause>);
12681269
if (Itr != ExistingClauses.end()) {
12691270
SemaRef.Diag(Clause.getBeginLoc(), diag::err_acc_loop_spec_conflict)
12701271
<< Clause.getClauseKind() << Clause.getDirectiveKind();
@@ -1281,7 +1282,8 @@ OpenACCClause *SemaOpenACCClauseVisitor::VisitIndependentClause(
12811282
// OpenACC 3.3 2.9:
12821283
// Only one of the seq, independent, and auto clauses may appear.
12831284
const auto *Itr = llvm::find_if(
1284-
ExistingClauses, llvm::IsaPred<OpenACCAutoClause, OpenACCSeqClause>);
1285+
ExistingClauses, llvm::IsaPred<OpenACCIndependentClause,
1286+
OpenACCAutoClause, OpenACCSeqClause>);
12851287
if (Itr != ExistingClauses.end()) {
12861288
SemaRef.Diag(Clause.getBeginLoc(), diag::err_acc_loop_spec_conflict)
12871289
<< Clause.getClauseKind() << Clause.getDirectiveKind();
@@ -1798,7 +1800,8 @@ OpenACCClause *SemaOpenACCClauseVisitor::VisitSeqClause(
17981800
// Only one of the seq, independent, and auto clauses may appear.
17991801
const auto *Itr =
18001802
llvm::find_if(ExistingClauses,
1801-
llvm::IsaPred<OpenACCAutoClause, OpenACCIndependentClause>);
1803+
llvm::IsaPred<OpenACCAutoClause, OpenACCIndependentClause,
1804+
OpenACCSeqClause>);
18021805
if (Itr != ExistingClauses.end()) {
18031806
SemaRef.Diag(Clause.getBeginLoc(), diag::err_acc_loop_spec_conflict)
18041807
<< Clause.getClauseKind() << Clause.getDirectiveKind();

clang/test/SemaOpenACC/loop-construct-auto_seq_independent-clauses.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,19 @@ void uses() {
3333
#pragma acc loop independent seq
3434
for(unsigned i = 0; i < 5; ++i);
3535

36+
// expected-error@+2{{OpenACC clause 'seq' on 'loop' construct conflicts with previous data dependence clause}}
37+
// expected-note@+1{{previous clause is here}}
38+
#pragma acc loop seq seq
39+
for(unsigned i = 0; i < 5; ++i);
40+
// expected-error@+2{{OpenACC clause 'independent' on 'loop' construct conflicts with previous data dependence clause}}
41+
// expected-note@+1{{previous clause is here}}
42+
#pragma acc loop independent independent
43+
for(unsigned i = 0; i < 5; ++i);
44+
// expected-error@+2{{OpenACC clause 'auto' on 'loop' construct conflicts with previous data dependence clause}}
45+
// expected-note@+1{{previous clause is here}}
46+
#pragma acc loop auto auto
47+
for(unsigned i = 0; i < 5; ++i);
48+
3649
int Var;
3750
int *VarPtr;
3851

0 commit comments

Comments
 (0)