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

Sergio Afonso via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 13 06:24:30 PDT 2024


================
@@ -2357,6 +2438,49 @@ bool OmpStructureChecker::CheckReductionOperators(
 
   return ok;
 }
+
+void OmpStructureChecker::addModifiertoMap(const parser::OmpObjectList &x,
+    parser::OmpReductionClause::ReductionModifier &modifier) {
+  for (const auto &ompObject : x.v) {
+    if (const auto *name{parser::Unwrap<parser::Name>(ompObject)}) {
+      if (const auto *symbol{name->symbol}) {
+        GetContext().reductionMod[symbol->name().ToString()] = modifier;
+      }
+    }
+  }
+}
+
+void OmpStructureChecker::checkAndAddSymbolsToUsedInScanList(
+    const parser::OmpObjectList &x) {
+  for (const auto &ompObj : x.v) {
+    common::visit(
+        common::visitors{
+            [&](const parser::Designator &designator) {
+              if (const auto *name{
+                      semantics::getDesignatorNameIfDataRef(designator)}) {
+                if (name->symbol) {
+                  if (CurrentDirectiveIsNested()) {
+                    std::string nameStr = name->symbol->name().ToString();
+                    if (GetContextParent().reductionMod.find(nameStr) ==
+                        GetContextParent().reductionMod.end()) {
+
+                      context_.Say(name->source,
+                          "List item %s must appear in 'reduction' clause "
+                          "with the 'inscan' modifier of the parent "
+                          "directive"_err_en_US,
+                          nameStr);
+                    }
+                    GetContextParent().usedInScanDirective.insert(nameStr);
+                  }
+                }
+              }
+            },
+            [&](const auto &name) {},
----------------
skatrak wrote:

Same as the comment above: support common blocks (if allowed) by sharing implementation with the case above.

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


More information about the llvm-commits mailing list