[flang-commits] [flang] d94c042 - [flang][openacc] Restrict branching out of data construct

Valentin Clement via flang-commits flang-commits at lists.llvm.org
Mon Aug 21 08:37:58 PDT 2023


Author: Valentin Clement
Date: 2023-08-21T08:37:52-07:00
New Revision: d94c042b6b1f539734e307f069eebe42ec5db76e

URL: https://github.com/llvm/llvm-project/commit/d94c042b6b1f539734e307f069eebe42ec5db76e
DIFF: https://github.com/llvm/llvm-project/commit/d94c042b6b1f539734e307f069eebe42ec5db76e.diff

LOG: [flang][openacc] Restrict branching out of data construct

This restriction is not clearly stated in the OpenACC standard
but all other compilers enforce it and there no explanation to
what should happen if there is a branching out of the construct.
Add the restriction for now.

Reviewed By: vzakhari

Differential Revision: https://reviews.llvm.org/D158319

Added: 
    

Modified: 
    flang/lib/Semantics/check-acc-structure.cpp
    flang/test/Semantics/OpenACC/acc-branch.f90

Removed: 
    


################################################################################
diff  --git a/flang/lib/Semantics/check-acc-structure.cpp b/flang/lib/Semantics/check-acc-structure.cpp
index e8d55aa9bdd2e4..b72326571b4fb5 100644
--- a/flang/lib/Semantics/check-acc-structure.cpp
+++ b/flang/lib/Semantics/check-acc-structure.cpp
@@ -149,6 +149,9 @@ void AccStructureChecker::Leave(const parser::OpenACCBlockConstruct &x) {
   case llvm::acc::Directive::ACCD_data:
     // Restriction - line 1249-1250
     CheckRequireAtLeastOneOf();
+    // Restriction is not formally in the specification but all compilers emit
+    // an error and it is likely to be omitted from the spec.
+    CheckNoBranching(block, GetContext().directive, blockDir.source);
     break;
   case llvm::acc::Directive::ACCD_host_data:
     // Restriction - line 1746

diff  --git a/flang/test/Semantics/OpenACC/acc-branch.f90 b/flang/test/Semantics/OpenACC/acc-branch.f90
index 9035775a3f765e..c05633d2576e2c 100644
--- a/flang/test/Semantics/OpenACC/acc-branch.f90
+++ b/flang/test/Semantics/OpenACC/acc-branch.f90
@@ -167,4 +167,12 @@ program openacc_clause_validity
   end do
   !$acc end serial
 
+
+  !$acc data create(a)
+
+  !ERROR: RETURN statement is not allowed in a DATA construct
+  if (size(a) == 10) return
+
+  !$acc end data
+
 end program openacc_clause_validity


        


More information about the flang-commits mailing list