[flang-commits] [flang] [llvm] [Flang][OpenMP][Sema] Adding parsing and semantic support for scan directive. (PR #102792)

Anchu Rajendran S via flang-commits flang-commits at lists.llvm.org
Thu Nov 14 12:13:07 PST 2024


================
@@ -70,6 +72,43 @@ class OmpStructureChecker
         ) {
   }
   using llvmOmpClause = const llvm::omp::Clause;
+  using ReductionModifier = parser::OmpReductionClause::ReductionModifier;
+  using Symbol = Fortran::semantics::Symbol;
+  class ScanReductionInfo {
+    std::set<Symbol *> usedInScan;
+    std::map<Symbol *, ReductionModifier> reductionMod;
----------------
anchuraj wrote:

I am trying to implement the alternative approach. The other alternative is as follows
-  to mark Symbol with `reduction Modifier` (using a flag or field)
- when scan directive is encountered, if `reductionmodifier` is not `inscan`, or flag is not `reduction`, error should be emitted.
- when loop directive is exited, for reduction variables, if flag is not `inclusive` or `exclusive` , error should be emitted. 
- Since reduction  declares a new symbol, and scan directive is closely nested within reduction, I believe stack is redundant for all valid programs (other semantic checks catches those errors)

I believe an extra flag should simplify the code.



https://github.com/llvm/llvm-project/pull/102792


More information about the flang-commits mailing list