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

Anchu Rajendran S via llvm-commits llvm-commits at lists.llvm.org
Thu Nov 14 11:47:53 PST 2024


================
@@ -751,7 +759,47 @@ void OmpStructureChecker::CheckDistLinear(
   }
 }
 
-void OmpStructureChecker::Leave(const parser::OpenMPLoopConstruct &) {
+void OmpStructureChecker::Leave(const parser::OpenMPLoopConstruct &x) {
+  const auto &beginLoopDir{std::get<parser::OmpBeginLoopDirective>(x.t)};
+  const auto &clauseList{std::get<parser::OmpClauseList>(beginLoopDir.t)};
+  for (const auto &clause : clauseList.v) {
+    if (const auto *reductionClause{
+            std::get_if<parser::OmpClause::Reduction>(&clause.u)}) {
+      const auto &maybeModifier{
+          std::get<std::optional<ReductionModifier>>(reductionClause->v.t)};
+      if (maybeModifier && *maybeModifier == ReductionModifier::Inscan) {
+
+        const auto &objectList{
+            std::get<parser::OmpObjectList>(reductionClause->v.t)};
+        auto checkReductionSymbolInScan = [&](const parser::Name *name) {
+          if (name->symbol) {
+            std::string nameStr = name->symbol->name().ToString();
+            if (GetContext().usedInScanDirective.find(nameStr) ==
+                GetContext().usedInScanDirective.end()) {
+              context_.Say(name->source,
+                  "List item %s must appear in 'inclusive' or "
+                  "'exclusive' clause of an "
+                  "enclosed scan directive"_err_en_US,
----------------
anchuraj wrote:

Changed

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


More information about the llvm-commits mailing list