[flang-commits] [flang] [Flang][OpenMP] Allow zero trait score (PR #131473)

Kiran Chandramohan via flang-commits flang-commits at lists.llvm.org
Sat Mar 15 14:32:01 PDT 2025


https://github.com/kiranchandramohan created https://github.com/llvm/llvm-project/pull/131473

None

>From 1e5786e0949514563911911ad8118b1e73dda930 Mon Sep 17 00:00:00 2001
From: Kiran Chandramohan <kiran.chandramohan at arm.com>
Date: Sat, 15 Mar 2025 21:25:50 +0000
Subject: [PATCH] [Flang][OpenMP] Allow zero trait score

---
 flang/lib/Semantics/check-omp-structure.cpp          | 2 +-
 flang/test/Semantics/OpenMP/metadirective-common.f90 | 5 +++++
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/flang/lib/Semantics/check-omp-structure.cpp b/flang/lib/Semantics/check-omp-structure.cpp
index 5fcebdca0bc5f..1da47be2fbf18 100644
--- a/flang/lib/Semantics/check-omp-structure.cpp
+++ b/flang/lib/Semantics/check-omp-structure.cpp
@@ -4942,7 +4942,7 @@ void OmpStructureChecker::CheckTraitSetSelector(
 void OmpStructureChecker::CheckTraitScore(const parser::OmpTraitScore &score) {
   // [6.0:322:23]
   // A score-expression must be a non-negative constant integer expression.
-  if (auto value{GetIntValue(score)}; !value || value <= 0) {
+  if (auto value{GetIntValue(score)}; !value || value < 0) {
     context_.Say(score.source,
         "SCORE expression must be a non-negative constant integer expression"_err_en_US);
   }
diff --git a/flang/test/Semantics/OpenMP/metadirective-common.f90 b/flang/test/Semantics/OpenMP/metadirective-common.f90
index 4988fae9e8edc..9225048ece3c1 100644
--- a/flang/test/Semantics/OpenMP/metadirective-common.f90
+++ b/flang/test/Semantics/OpenMP/metadirective-common.f90
@@ -21,6 +21,11 @@ subroutine f02
   !$omp & when(user={condition(score(-2): .true.)}: nothing)
 end
 
+subroutine f02_zero_score
+  !$omp metadirective &
+  !$omp & when(user={condition(score(0): .true.)}: nothing)
+end
+
 subroutine f03(x)
   integer :: x
   !$omp metadirective &



More information about the flang-commits mailing list