[PATCH] D119141: The device expression must evaluate to a non-negative integer value.

Harshil Jani via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Feb 8 04:58:19 PST 2022


Harshil-Jani updated this revision to Diff 406775.
Herald added subscribers: llvm-commits, dexonsmith, hiraditya.
Herald added a project: LLVM.

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D119141/new/

https://reviews.llvm.org/D119141

Files:
  flang/lib/Semantics/check-directive-structure.h
  flang/lib/Semantics/check-omp-structure.cpp
  flang/test/Semantics/omp-device-constructs.f90
  llvm/lib/Support/FormatVariadic.cpp


Index: llvm/lib/Support/FormatVariadic.cpp
===================================================================
--- llvm/lib/Support/FormatVariadic.cpp
+++ llvm/lib/Support/FormatVariadic.cpp
@@ -18,8 +18,10 @@
     return AlignStyle::Center;
   case '+':
     return AlignStyle::Right;
+  default:
+    return None;
   }
-  return None;
+  LLVM_BUILTIN_UNREACHABLE;
 }
 
 bool formatv_object_base::consumeFieldLayout(StringRef &Spec, AlignStyle &Where,
Index: flang/test/Semantics/omp-device-constructs.f90
===================================================================
--- flang/test/Semantics/omp-device-constructs.f90
+++ flang/test/Semantics/omp-device-constructs.f90
@@ -29,6 +29,12 @@
   enddo
   !$omp end target
 
+  !ERROR: The parameter of the DEVICE clause must be a positive integer expression
+  !$omp target enter data map(alloc:A) device(-2)
+
+  !ERROR: The parameter of the DEVICE clause must be a positive integer expression
+  !$omp target exit data map(delete:A) device(-2)
+
   !ERROR: SCHEDULE clause is not allowed on the TARGET directive
   !$omp target schedule(static)
   do i = 1, N
Index: flang/lib/Semantics/check-omp-structure.cpp
===================================================================
--- flang/lib/Semantics/check-omp-structure.cpp
+++ flang/lib/Semantics/check-omp-structure.cpp
@@ -1656,7 +1656,6 @@
 CHECK_SIMPLE_CLAUSE(Depobj, OMPC_depobj)
 CHECK_SIMPLE_CLAUSE(Destroy, OMPC_destroy)
 CHECK_SIMPLE_CLAUSE(Detach, OMPC_detach)
-CHECK_SIMPLE_CLAUSE(Device, OMPC_device)
 CHECK_SIMPLE_CLAUSE(DeviceType, OMPC_device_type)
 CHECK_SIMPLE_CLAUSE(DistSchedule, OMPC_dist_schedule)
 CHECK_SIMPLE_CLAUSE(DynamicAllocators, OMPC_dynamic_allocators)
@@ -1721,6 +1720,7 @@
 CHECK_REQ_SCALAR_INT_CLAUSE(NumThreads, OMPC_num_threads)
 CHECK_REQ_SCALAR_INT_CLAUSE(Priority, OMPC_priority)
 CHECK_REQ_SCALAR_INT_CLAUSE(ThreadLimit, OMPC_thread_limit)
+CHECK_REQ_SCALAR_INT_CLAUSE(Device, OMPC_device)
 
 CHECK_REQ_CONSTANT_SCALAR_INT_CLAUSE(Collapse, OMPC_collapse)
 CHECK_REQ_CONSTANT_SCALAR_INT_CLAUSE(Safelen, OMPC_safelen)
Index: flang/lib/Semantics/check-directive-structure.h
===================================================================
--- flang/lib/Semantics/check-directive-structure.h
+++ flang/lib/Semantics/check-directive-structure.h
@@ -551,7 +551,7 @@
     ClauseEnumSize>::RequiresPositiveParameter(const C &clause,
     const parser::ScalarIntExpr &i, llvm::StringRef paramName) {
   if (const auto v{GetIntValue(i)}) {
-    if (*v <= 0) {
+    if (*v < 0) {
       context_.Say(GetContext().clauseSource,
           "The %s of the %s clause must be "
           "a positive integer expression"_err_en_US,


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D119141.406775.patch
Type: text/x-patch
Size: 2668 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220208/e2b37b7e/attachment.bin>


More information about the llvm-commits mailing list