[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
Wed Jul 16 22:38:40 PDT 2025
https://github.com/Ritanya-B-Bharadwaj updated https://github.com/llvm/llvm-project/pull/148583
>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 1/2] [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();
>From 8c75b3c2b6e4e0aa068307e6324f4d83b894d558 Mon Sep 17 00:00:00 2001
From: Ritanya B Bharadwaj <ritanya.b.bharadwaj at gmail.com>
Date: Thu, 17 Jul 2025 00:37:04 -0500
Subject: [PATCH 2/2] Adding a lit test case
---
clang/test/OpenMP/metadirective_ast_print.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/clang/test/OpenMP/metadirective_ast_print.c b/clang/test/OpenMP/metadirective_ast_print.c
index 638dbae1bc774..702d441eb193d 100644
--- a/clang/test/OpenMP/metadirective_ast_print.c
+++ b/clang/test/OpenMP/metadirective_ast_print.c
@@ -108,6 +108,12 @@ void foo1(void) {
: parallel) otherwise(parallel for)
for (int i=0; i<10; i++)
;
+
+#pragma omp metadirective when(user = {condition(1)} \
+ : parallel for) when(implementation = {extension(match_none)} \
+ : parallel)
+ for (int i=0; i<10; i++)
+ ;
}
// OMP52: void bar(void);
More information about the cfe-commits
mailing list