[clang] [Clang][OpenMP] Fixed an assertion on omp taskloop transparent (PR #200663)

via cfe-commits cfe-commits at lists.llvm.org
Sun Jun 14 06:57:17 PDT 2026


https://github.com/TPPPP72 updated https://github.com/llvm/llvm-project/pull/200663

>From b5c6d1f6ca7c8bd651785923b3527e50b2d2b759 Mon Sep 17 00:00:00 2001
From: TPPPP <TPPPP72 at outlook.com>
Date: Sun, 31 May 2026 23:05:04 +0800
Subject: [PATCH 1/2] [Clang][OpenMP] Fixed an assertion on omp taskloop
 transparent

---
 clang/docs/ReleaseNotes.rst      | 1 +
 clang/lib/Sema/SemaOpenMP.cpp    | 5 +++++
 clang/test/SemaOpenMP/gh197162.c | 6 ++++++
 3 files changed, 12 insertions(+)
 create mode 100644 clang/test/SemaOpenMP/gh197162.c

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index fc0a1d2d4c926..cae8238c66138 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -652,6 +652,7 @@ Bug Fixes in This Version
 - Fixed an issue where certain designated initializers would be rejected for constexpr variables. (#GH193373)
 - Fixed a crash when ``#embed`` is used with C++ modules (#GH195350)
 - Fixed crash when checking for overflow for unary operator that can't overflow (#GH170072)
+- Fixed an assertion on omp taskloop transparent (#GH197162)
 
 Bug Fixes to Compiler Builtins
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
diff --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp
index 76b40a5039180..50f8438acec08 100644
--- a/clang/lib/Sema/SemaOpenMP.cpp
+++ b/clang/lib/Sema/SemaOpenMP.cpp
@@ -17811,6 +17811,11 @@ OMPClause *SemaOpenMP::ActOnOpenMPTransparentClause(Expr *ImpexTypeArg,
                                                     SourceLocation EndLoc) {
   Stmt *HelperValStmt = nullptr;
   OpenMPDirectiveKind DKind = DSAStack->getCurrentDirective();
+
+  if (!isAllowedClauseForDirective(DKind, OMPC_transparent,
+                                   getLangOpts().OpenMP))
+    return nullptr;
+
   OpenMPDirectiveKind CaptureRegion = getOpenMPCaptureRegionForClause(
       DKind, OMPC_transparent, getLangOpts().OpenMP);
   if (CaptureRegion != OMPD_unknown &&
diff --git a/clang/test/SemaOpenMP/gh197162.c b/clang/test/SemaOpenMP/gh197162.c
new file mode 100644
index 0000000000000..42d8d987ac8b4
--- /dev/null
+++ b/clang/test/SemaOpenMP/gh197162.c
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -fopenmp -fsyntax-only %s
+
+void foo() {
+#pragma omp taskloop transparent // expected-error {{unexpected OpenMP clause 'transparent' in directive '#pragma omp taskloop'}}
+    for(int i = 0; i < 2; i++);
+}

>From 0cfbd5c68806bb2fdffcbcca0629e72a4f874b78 Mon Sep 17 00:00:00 2001
From: TPPPP <TPPPP72 at outlook.com>
Date: Sun, 31 May 2026 23:29:57 +0800
Subject: [PATCH 2/2] fix test

---
 clang/test/SemaOpenMP/gh197162.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang/test/SemaOpenMP/gh197162.c b/clang/test/SemaOpenMP/gh197162.c
index 42d8d987ac8b4..ffdf2ec3c3d8e 100644
--- a/clang/test/SemaOpenMP/gh197162.c
+++ b/clang/test/SemaOpenMP/gh197162.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fopenmp -fsyntax-only %s
+// RUN: %clang_cc1 -fopenmp -fsyntax-only -verify %s
 
 void foo() {
 #pragma omp taskloop transparent // expected-error {{unexpected OpenMP clause 'transparent' in directive '#pragma omp taskloop'}}



More information about the cfe-commits mailing list