[flang-commits] [flang] [Flang][OpenMP] Add some semantic checks for Linear clause (PR #111354)

Krzysztof Parzyszek via flang-commits flang-commits at lists.llvm.org
Mon Dec 2 08:35:34 PST 2024


================
@@ -323,6 +323,30 @@ void OmpStructureChecker::CheckMultListItems() {
     CheckMultipleOccurrence(
         listVars, nontempNameList, itr->second->source, "NONTEMPORAL");
   }
+
+  // Linear clause
+  auto linearClauses{FindClauses(llvm::omp::Clause::OMPC_linear)};
+  for (auto itr{linearClauses.first}; itr != linearClauses.second; ++itr) {
+    const auto &linearClause{
+        std::get<parser::OmpClause::Linear>(itr->second->u)};
+    std::list<parser::Name> nameList;
+    common::visit(
+        common::visitors{
+            [&](const parser::OmpLinearClause::WithoutModifier
+                    &withoutModifier) {
+              for (const auto &name : withoutModifier.names) {
+                nameList.push_back(name);
+              }
+            },
+            [&](const parser::OmpLinearClause::WithModifier &withModifier) {
+              for (const auto &name : withModifier.names) {
+                nameList.push_back(name);
+              }
+            },
+        },
----------------
kparzysz wrote:

You can only have a single visitor, plus you can simplify the copy:
```
[&](auto &&s) {
  std::copy(s.names.begin(), s.names.end(), std::back_inserter(nameList));
}
```

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


More information about the flang-commits mailing list