llvmorg-github-actions[bot] wrote:

<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clang

Author: TPPPP (TPPPP72)

<details>
<summary>Changes</summary>

Added checker in `Sema` to avoid assertion.
fix #<!-- -->197162 

---
Full diff: https://github.com/llvm/llvm-project/pull/200663.diff


3 Files Affected:

- (modified) clang/docs/ReleaseNotes.rst (+1) 
- (modified) clang/lib/Sema/SemaOpenMP.cpp (+4) 
- (added) clang/test/SemaOpenMP/gh197162.c (+6) 


``````````diff
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..9b83b719abc0f 100644
--- a/clang/lib/Sema/SemaOpenMP.cpp
+++ b/clang/lib/Sema/SemaOpenMP.cpp
@@ -17811,6 +17811,10 @@ 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..d1e464b838783
--- /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++);
+}

``````````

</details>


https://github.com/llvm/llvm-project/pull/200663
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to