[clang] [Clang][OpenMP] Assertion `!isNull() && "Cannot retrieve a NULL type pointer"' failed. (PR #81015)

via cfe-commits cfe-commits at lists.llvm.org
Wed Feb 7 09:36:27 PST 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clang

Author: Shourya Goel (Sh0g0-1758)

<details>
<summary>Changes</summary>

Fixes : #<!-- -->69085 , #<!-- -->69200

**PR SUMMARY**: "Added Null check for negative sized array and a test for the same"

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


2 Files Affected:

- (modified) clang/lib/Sema/SemaOpenMP.cpp (+2) 
- (added) clang/test/OpenMP/bug69085.c (+10) 


``````````diff
diff --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp
index 1556f6e8546135..1f73fe6f8742e3 100644
--- a/clang/lib/Sema/SemaOpenMP.cpp
+++ b/clang/lib/Sema/SemaOpenMP.cpp
@@ -21124,6 +21124,8 @@ Sema::ActOnOpenMPDependClause(const OMPDependClause::DependDataTy &Data,
               ExprTy = ATy->getElementType();
             else
               ExprTy = BaseType->getPointeeType();
+            if (ExprTy.isNull())
+              continue;
             ExprTy = ExprTy.getNonReferenceType();
             const Expr *Length = OASE->getLength();
             Expr::EvalResult Result;
diff --git a/clang/test/OpenMP/bug69085.c b/clang/test/OpenMP/bug69085.c
new file mode 100644
index 00000000000000..1017ea53b41e3d
--- /dev/null
+++ b/clang/test/OpenMP/bug69085.c
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -verify -O0 -fopenmp-simd %s
+
+int k[-1]; // expected-error {{'k' declared as an array with a negative size}}
+
+void foo() {
+    #pragma omp task depend(inout: k [:])
+    {
+        k[0] = 1;
+    }
+}

``````````

</details>


https://github.com/llvm/llvm-project/pull/81015


More information about the cfe-commits mailing list