Skip to content

Commit e3950a0

Browse files
committed
[OpenACC] Fix 'vector' checking when inside combined construct
For some reason when implementing 'vector' I didn't include switch entries for the combined constructs. I audited the rest of the uses of this pattern, and got it right everywhere else, so I'm not sure why I missed it here. Fixes: llvm#140339
1 parent b24c33a commit e3950a0

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

clang/lib/Sema/SemaOpenACCClause.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1271,17 +1271,20 @@ OpenACCClause *SemaOpenACCClauseVisitor::VisitVectorClause(
12711271
switch (SemaRef.getActiveComputeConstructInfo().Kind) {
12721272
case OpenACCDirectiveKind::Invalid:
12731273
case OpenACCDirectiveKind::Parallel:
1274+
case OpenACCDirectiveKind::ParallelLoop:
12741275
// No restriction on when 'parallel' can contain an argument.
12751276
break;
12761277
case OpenACCDirectiveKind::Serial:
1278+
case OpenACCDirectiveKind::SerialLoop:
12771279
// GCC disallows this, and there is no real good reason for us to permit
12781280
// it, so disallow until we come up with a use case that makes sense.
12791281
DiagIntArgInvalid(SemaRef, IntExpr, "length", OpenACCClauseKind::Vector,
12801282
Clause.getDirectiveKind(),
12811283
SemaRef.getActiveComputeConstructInfo().Kind);
12821284
IntExpr = nullptr;
12831285
break;
1284-
case OpenACCDirectiveKind::Kernels: {
1286+
case OpenACCDirectiveKind::Kernels:
1287+
case OpenACCDirectiveKind::KernelsLoop: {
12851288
const auto *Itr =
12861289
llvm::find_if(SemaRef.getActiveComputeConstructInfo().Clauses,
12871290
llvm::IsaPred<OpenACCVectorLengthClause>);

clang/test/SemaOpenACC/gh140339.cpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// RUN: %clang_cc1 %s -fopenacc -verify
2+
3+
void foo() {
4+
#pragma acc parallel loop
5+
for (int i = 0; i < 5; ++i) {
6+
#pragma acc loop vector(1)
7+
for(int j = 0; j < 5; ++j);
8+
}
9+
10+
#pragma acc serial loop
11+
for (int i = 0; i < 5; ++i) {
12+
// expected-error@+1{{'length' argument on 'vector' clause is not permitted on a 'loop' construct associated with a 'serial loop' compute construct}}
13+
#pragma acc loop vector(1)
14+
for(int j = 0; j < 5; ++j);
15+
}
16+
17+
#pragma acc kernels loop
18+
for (int i = 0; i < 5; ++i) {
19+
#pragma acc loop vector(1)
20+
for(int j = 0; j < 5; ++j);
21+
}
22+
}

0 commit comments

Comments
 (0)