[clang] [Clang][OpenMP] Fixing Clang error for metadirective with multiple when clauses and no otherwise (PR #148583)

via cfe-commits cfe-commits at lists.llvm.org
Mon Jul 14 01:21:23 PDT 2025


https://github.com/Ritanya-B-Bharadwaj created https://github.com/llvm/llvm-project/pull/148583

Fixing - https://github.com/llvm/llvm-project/issues/147336

>From cc247bc1eb330dd2d3ccebabc7c1d3b524073627 Mon Sep 17 00:00:00 2001
From: Ritanya B Bharadwaj <ritanya.b.bharadwaj at gmail.com>
Date: Mon, 14 Jul 2025 03:18:25 -0500
Subject: [PATCH] [Clang][OpenMP] Fixing error - 147336

---
 clang/lib/Parse/ParseOpenMP.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang/lib/Parse/ParseOpenMP.cpp b/clang/lib/Parse/ParseOpenMP.cpp
index aa6a0c61a2c17..5db2f2e2ccf86 100644
--- a/clang/lib/Parse/ParseOpenMP.cpp
+++ b/clang/lib/Parse/ParseOpenMP.cpp
@@ -2704,7 +2704,7 @@ StmtResult Parser::ParseOpenMPDeclarativeOrExecutableDirective(
     // If no match is found and no otherwise clause is present, skip
     // OMP5.2 Chapter 7.4: If no otherwise clause is specified the effect is as
     // if one was specified without an associated directive variant.
-    if (BestIdx == -1 && Idx == 1) {
+    if (BestIdx == -1 && Idx > 0) {
       assert(Tok.is(tok::annot_pragma_openmp_end) &&
              "Expecting the end of the pragma here");
       ConsumeAnnotationToken();



More information about the cfe-commits mailing list