Skip to content

Commit 552e99f

Browse files
committed
Reverse logic; Update the error message for the nested gang loops
1 parent ce6bcb7 commit 552e99f

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

flang/lib/Semantics/check-acc-structure.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,10 @@ void AccStructureChecker::CheckNotInSameOrSubLevelLoopConstruct() {
293293
bool invalid{false};
294294
if (parentClause == llvm::acc::Clause::ACCC_gang &&
295295
cl == llvm::acc::Clause::ACCC_gang) {
296-
if (!IsInsideKernelsConstruct()) {
296+
if (IsInsideKernelsConstruct()) {
297+
context_.Say(GetContext().clauseSource,
298+
"Nested GANG loops are not allowed in the region of a KERNELS construct"_err_en_US);
299+
} else {
297300
auto parentDim = getGangDimensionSize(parent);
298301
auto currentDim = getGangDimensionSize(GetContext());
299302
std::int64_t parentDimNum = 1, currentDimNum = 1;
@@ -317,8 +320,6 @@ void AccStructureChecker::CheckNotInSameOrSubLevelLoopConstruct() {
317320
parentDimStr);
318321
continue;
319322
}
320-
} else {
321-
invalid = true;
322323
}
323324
} else if (parentClause == llvm::acc::Clause::ACCC_worker &&
324325
(cl == llvm::acc::Clause::ACCC_gang ||

flang/test/Semantics/OpenACC/acc-loop.f90

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -340,10 +340,10 @@ program openacc_loop_validity
340340

341341
!$acc kernels loop gang(dim:3)
342342
do i = 1, n
343-
!ERROR: GANG clause is not allowed in the region of a loop with the GANG clause
343+
!ERROR: Nested GANG loops are not allowed in the region of a KERNELS construct
344344
!$acc loop gang(dim:2)
345345
do j = 1, n
346-
!ERROR: GANG clause is not allowed in the region of a loop with the GANG clause
346+
!ERROR: Nested GANG loops are not allowed in the region of a KERNELS construct
347347
!$acc loop gang(dim:1) worker vector
348348
do k = 1, i
349349
end do

0 commit comments

Comments
 (0)