[clang] b89eb97 - [Clang][OpenMP] Fix `!isNull() && "Cannot retrieve a NULL type pointer"' fail. (#81015)
via cfe-commits
cfe-commits at lists.llvm.org
Wed Feb 7 11:38:26 PST 2024
Author: Shourya Goel
Date: 2024-02-07T13:38:22-06:00
New Revision: b89eb9790a8962ca634965d05491a93c58773faf
URL: https://github.com/llvm/llvm-project/commit/b89eb9790a8962ca634965d05491a93c58773faf
DIFF: https://github.com/llvm/llvm-project/commit/b89eb9790a8962ca634965d05491a93c58773faf.diff
LOG: [Clang][OpenMP] Fix `!isNull() && "Cannot retrieve a NULL type pointer"' fail. (#81015)
Fixes : #69085 , #69200
**PR SUMMARY**: "Added Null check for negative sized array and a test
for the same"
Added:
clang/test/OpenMP/bug69085.c
Modified:
clang/lib/Sema/SemaOpenMP.cpp
Removed:
################################################################################
diff --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp
index 1556f6e8546135..7f75cfc5b54f35 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 (BaseType.isNull() || ExprTy.isNull())
+ return nullptr;
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;
+ }
+}
More information about the cfe-commits
mailing list