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

Thirumalai Shaktivel via flang-commits flang-commits at lists.llvm.org
Fri Dec 6 06:49:36 PST 2024


================
@@ -3542,16 +3557,98 @@ void OmpStructureChecker::Enter(const parser::OmpClause::If &x) {
 void OmpStructureChecker::Enter(const parser::OmpClause::Linear &x) {
   CheckAllowedClause(llvm::omp::Clause::OMPC_linear);
 
+  parser::CharBlock source{GetContext().clauseSource};
   // 2.7 Loop Construct Restriction
   if ((llvm::omp::allDoSet | llvm::omp::allSimdSet)
           .test(GetContext().directive)) {
     if (std::holds_alternative<parser::OmpLinearClause::WithModifier>(x.v.u)) {
-      context_.Say(GetContext().clauseSource,
+      context_.Say(source,
           "A modifier may not be specified in a LINEAR clause "
           "on the %s directive"_err_en_US,
           ContextDirectiveAsFortran());
+      return;
+    }
+  }
+
+  // OpenMP 5.2: Ordered clause restriction
+  if (const auto *clause{
+          FindClause(GetContext(), llvm::omp::Clause::OMPC_ordered)}) {
+    const auto &orderedClause{std::get<parser::OmpClause::Ordered>(clause->u)};
+    if (orderedClause.v) {
+      return;
     }
   }
+
+  auto checkForValidLinearClause_01 = [&](const parser::Name &name,
+                                          bool is_ref) {
----------------
Thirumalai-Shaktivel wrote:

I'm sorry, but I'm not getting this.

Concatenate in the sense, for the following:
```
context_.Say(source,
          "The list item `%s` specified with other than linear-modifier `REF`"
          " must be of type INTEGER"_err_en_US,
          listItemName);
```
should I do?
```
context_.Say(source,
          "The list item `%s` specified with other than linear-modifier `REF` must be of type INTEGER"_err_en_US,
          listItemName);
```

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


More information about the flang-commits mailing list