Skip to content

[flang][openacc] Keep CYCLE check for compute and data construct #73897

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion flang/lib/Semantics/check-directive-structure.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,17 @@ template <typename D> class NoBranchingEnforce {
break;
}
} else if constexpr (std::is_same_v<D, llvm::acc::Directive>) {
return; // OpenACC construct do not need check for unlabelled CYCLES
switch ((llvm::acc::Directive)currentDirective_) {
// exclude loop directives which do not need a check for unlabelled
// CYCLES
case llvm::acc::Directive::ACCD_loop:
case llvm::acc::Directive::ACCD_kernels_loop:
case llvm::acc::Directive::ACCD_parallel_loop:
case llvm::acc::Directive::ACCD_serial_loop:
return;
default:
break;
}
}
CheckConstructNameBranching("CYCLE");
}
Expand Down
13 changes: 13 additions & 0 deletions flang/test/Semantics/OpenACC/acc-data.f90
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,19 @@ program openacc_data_validity
!$acc data copy(aa) device_type(default) wait
!$acc end data

do i = 1, 100
!$acc data copy(aa)
!ERROR: CYCLE to construct outside of DATA construct is not allowed
if (i == 10) cycle
!$acc end data
end do

!$acc data copy(aa)
do i = 1, 100
if (i == 10) cycle
end do
!$acc end data

end program openacc_data_validity

module mod1
Expand Down
13 changes: 13 additions & 0 deletions flang/test/Semantics/OpenACC/acc-kernels.f90
Original file line number Diff line number Diff line change
Expand Up @@ -144,4 +144,17 @@ program openacc_kernels_validity
end do
!$acc end kernels

do i = 1, 100
!$acc kernels
!ERROR: CYCLE to construct outside of KERNELS construct is not allowed
if (i == 10) cycle
!$acc end kernels
end do

!$acc kernels
do i = 1, 100
if (i == 10) cycle
end do
!$acc end kernels

end program openacc_kernels_validity
13 changes: 13 additions & 0 deletions flang/test/Semantics/OpenACC/acc-parallel.f90
Original file line number Diff line number Diff line change
Expand Up @@ -142,4 +142,17 @@ program openacc_parallel_validity
end do
!$acc end parallel

do i = 1, 100
!$acc parallel
!ERROR: CYCLE to construct outside of PARALLEL construct is not allowed
if (i == 10) cycle
!$acc end parallel
end do

!$acc parallel
do i = 1, 100
if (i == 10) cycle
end do
!$acc end parallel

end program openacc_parallel_validity
13 changes: 13 additions & 0 deletions flang/test/Semantics/OpenACC/acc-serial.f90
Original file line number Diff line number Diff line change
Expand Up @@ -166,4 +166,17 @@ program openacc_serial_validity
end do
!$acc end serial

do i = 1, 100
!$acc serial
!ERROR: CYCLE to construct outside of SERIAL construct is not allowed
if (i == 10) cycle
!$acc end serial
end do

!$acc serial
do i = 1, 100
if (i == 10) cycle
end do
!$acc end serial

end program openacc_serial_validity