[PATCH] D89546: [Flang][OpenMP 4.5] Add semantic check for OpenMP schedule clause

Yashaswini Hegde via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 16 05:56:24 PDT 2020


yhegde created this revision.
yhegde added reviewers: kiranchandramohan, richard.barton.arm, DavidTruby.
yhegde added projects: Flang, OpenMP, LLVM.
Herald added subscribers: llvm-commits, jdoerfert, guansong, yaxunl.
yhegde requested review of this revision.
Herald added a reviewer: jdoerfert.
Herald added a subscriber: sstefan1.

Semantic check for OpenMP 4.5 - 2.7.1 schedule clause

Test cases : omp-do-schedule.f90


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D89546

Files:
  flang/lib/Semantics/check-omp-structure.cpp
  flang/test/Semantics/omp-do-schedule.f90


Index: flang/test/Semantics/omp-do-schedule.f90
===================================================================
--- /dev/null
+++ flang/test/Semantics/omp-do-schedule.f90
@@ -0,0 +1,13 @@
+! RUN: %S/test_errors.sh %s %t %f18 -fopenmp
+! OpenMP Version 4.5
+! 2.7.1 Schedule Clause
+program omp_doSchedule
+  integer :: i,n
+  real ::  a(100), y(100), z(100)
+!ERROR: The chunk size of the schedule clause must be a positive integer.
+ !$omp do schedule(STATIC, -1)
+   do i=2,n+1
+      y(i) = z(i-1) + a(i)
+   end do
+ !$omp end do
+end program omp_doSchedule
Index: flang/lib/Semantics/check-omp-structure.cpp
===================================================================
--- flang/lib/Semantics/check-omp-structure.cpp
+++ flang/lib/Semantics/check-omp-structure.cpp
@@ -603,6 +603,18 @@
             parser::ToUpperCaseLetters(
                 parser::OmpScheduleClause::EnumToString(kind)));
       }
+      // OpenMP 4.5 : 2.7.1 Schedule clause
+      if (const auto &chunkExpr{
+              std::get<std::optional<parser::ScalarIntExpr>>(x.t)}) {
+        if (const auto chunkValue{GetIntValue(chunkExpr)}) {
+          if (*chunkValue <= 0) {
+            context_.Say(GetContext().clauseSource,
+                "The chunk size of the schedule clause must be a"
+                " positive integer."_err_en_US,
+                ContextDirectiveAsFortran());
+          }
+        }
+      }
     }
 
     if (ScheduleModifierHasType(


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D89546.298605.patch
Type: text/x-patch
Size: 1457 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20201016/914d98c5/attachment.bin>


More information about the llvm-commits mailing list