Author: Ritanya-B-Bharadwaj Date: 2025-08-05T20:02:44+05:30 New Revision: 1d594fdb8d0d210893ae346bb6869343dd7a1949
URL: https://github.com/llvm/llvm-project/commit/1d594fdb8d0d210893ae346bb6869343dd7a1949 DIFF: https://github.com/llvm/llvm-project/commit/1d594fdb8d0d210893ae346bb6869343dd7a1949.diff LOG: [Clang][OpenMP] Fixing Clang error for metadirective with multiple when clauses and no otherwise (#148583) Fixing - https://github.com/llvm/llvm-project/issues/147336 Added: Modified: clang/lib/Parse/ParseOpenMP.cpp clang/test/OpenMP/metadirective_messages.cpp Removed: ################################################################################ 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(); diff --git a/clang/test/OpenMP/metadirective_messages.cpp b/clang/test/OpenMP/metadirective_messages.cpp index 9d2934f8b1e10..7426f915bf99e 100644 --- a/clang/test/OpenMP/metadirective_messages.cpp +++ b/clang/test/OpenMP/metadirective_messages.cpp @@ -47,6 +47,10 @@ void foo() { ; #pragma omp metadirective when(device = {arch(nvptx)} : parallel) xyz() //expected-error {{expected at least one clause on '#pragma omp metadirective' directive}} ; + int a = 0; + int b = 1; + #pragma omp metadirective when(user={condition(a)}: parallel for simd) when(user={condition(b)}: target teams distribute parallel for simd) + for (int i = 0; i < 10; ++i) {} #endif } _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits