[flang-commits] [flang] [flang][openacc] Raise an error when UPDATE directive is in compute region (PR #217090)
via flang-commits
flang-commits at lists.llvm.org
Tue Aug 18 10:37:56 PDT 2026
llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-flang-semantics
Author: Valentin Clement (バレンタイン クレメン) (clementval)
<details>
<summary>Changes</summary>
This is in line with the reference compiler.
---
Full diff: https://github.com/llvm/llvm-project/pull/217090.diff
2 Files Affected:
- (modified) flang/lib/Semantics/check-acc-structure.cpp (+2)
- (modified) flang/test/Semantics/OpenACC/acc-update-validity.f90 (+63)
``````````diff
diff --git a/flang/lib/Semantics/check-acc-structure.cpp b/flang/lib/Semantics/check-acc-structure.cpp
index 84acf31aa4a58..25bc1de56120f 100644
--- a/flang/lib/Semantics/check-acc-structure.cpp
+++ b/flang/lib/Semantics/check-acc-structure.cpp
@@ -520,6 +520,8 @@ void AccStructureChecker::Leave(const parser::OpenACCStandaloneConstruct &x) {
// Restriction - line 2669
CheckOnlyAllowedAfter(llvm::acc::Clause::ACCC_device_type,
updateOnlyAllowedAfterDeviceTypeClauses);
+ // An update directive may not appear within a compute construct.
+ CheckNotInComputeConstruct();
break;
case llvm::acc::Directive::ACCD_init:
case llvm::acc::Directive::ACCD_shutdown:
diff --git a/flang/test/Semantics/OpenACC/acc-update-validity.f90 b/flang/test/Semantics/OpenACC/acc-update-validity.f90
index 8add56e81cf9e..3c7cfbdcdd158 100644
--- a/flang/test/Semantics/OpenACC/acc-update-validity.f90
+++ b/flang/test/Semantics/OpenACC/acc-update-validity.f90
@@ -64,4 +64,67 @@ program openacc_update_validity
!ERROR: Clause IF is not allowed after clause DEVICE_TYPE on the UPDATE directive
!$acc update device(i) device_type(*) if(.TRUE.)
+ !$acc parallel
+ !ERROR: Directive UPDATE may not be called within a compute region
+ !$acc update device(a)
+ !$acc end parallel
+
+ !$acc serial
+ !ERROR: Directive UPDATE may not be called within a compute region
+ !$acc update device(a)
+ !$acc end serial
+
+ !$acc kernels
+ !ERROR: Directive UPDATE may not be called within a compute region
+ !$acc update device(a)
+ !$acc end kernels
+
+ !$acc parallel
+ !$acc loop
+ do i = 1, N
+ !ERROR: Directive UPDATE may not be called within a compute region
+ !$acc update device(a)
+ a(i) = 3.14d0
+ end do
+ !$acc end parallel
+
+ !$acc serial
+ !$acc loop
+ do i = 1, N
+ !ERROR: Directive UPDATE may not be called within a compute region
+ !$acc update device(a)
+ a(i) = 3.14d0
+ end do
+ !$acc end serial
+
+ !$acc kernels
+ !$acc loop
+ do i = 1, N
+ !ERROR: Directive UPDATE may not be called within a compute region
+ !$acc update device(a)
+ a(i) = 3.14d0
+ end do
+ !$acc end kernels
+
+ !$acc parallel loop
+ do i = 1, N
+ !ERROR: Directive UPDATE may not be called within a compute region
+ !$acc update device(a)
+ a(i) = 3.14d0
+ end do
+
+ !$acc serial loop
+ do i = 1, N
+ !ERROR: Directive UPDATE may not be called within a compute region
+ !$acc update device(a)
+ a(i) = 3.14d0
+ end do
+
+ !$acc kernels loop
+ do i = 1, N
+ !ERROR: Directive UPDATE may not be called within a compute region
+ !$acc update device(a)
+ a(i) = 3.14d0
+ end do
+
end program openacc_update_validity
``````````
</details>
https://github.com/llvm/llvm-project/pull/217090
More information about the flang-commits
mailing list