[clang] [Clang][OpenMP] Assertion `!isNull() && "Cannot retrieve a NULL type pointer"' failed. (PR #81015)
Shourya Goel via cfe-commits
cfe-commits at lists.llvm.org
Wed Feb 7 09:35:58 PST 2024
https://github.com/Sh0g0-1758 created https://github.com/llvm/llvm-project/pull/81015
Fixes : #69085 , #69200
**PR SUMMARY**: "Added Null check for negative sized array and a test for the same"
>From c8ada809964eac64f6cb0c103593748b86932163 Mon Sep 17 00:00:00 2001
From: Sh0g0-1758 <shouryagoel10000 at gmail.com>
Date: Wed, 7 Feb 2024 21:11:58 +0530
Subject: [PATCH 1/4] Add a Null Check
---
clang/lib/Sema/SemaOpenMP.cpp | 2 ++
1 file changed, 2 insertions(+)
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;
>From 06bae9c5a4d73e52e6f0994d445dde8f6a578c2f Mon Sep 17 00:00:00 2001
From: Sh0g0-1758 <shouryagoel10000 at gmail.com>
Date: Wed, 7 Feb 2024 21:35:06 +0530
Subject: [PATCH 2/4] Added tests for Bug 69085
---
clang/test/OpenMP/bug69085.c | 7 +++++++
1 file changed, 7 insertions(+)
create mode 100644 clang/test/OpenMP/bug69085.c
diff --git a/clang/test/OpenMP/bug69085.c b/clang/test/OpenMP/bug69085.c
new file mode 100644
index 00000000000000..679d6fb3b092ce
--- /dev/null
+++ b/clang/test/OpenMP/bug69085.c
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -O0 -fopenmp-simd %s
+
+int k[-46];
+
+void foo() {
+#pragma omp task depend(inout: k [0.5:])
+}
>From 10ebc2428b285b115834fba35cd30a15fa13b46b Mon Sep 17 00:00:00 2001
From: Sh0g0-1758 <shouryagoel10000 at gmail.com>
Date: Wed, 7 Feb 2024 23:00:08 +0530
Subject: [PATCH 3/4] Added Test for Null check
---
clang/test/OpenMP/bug69085.c | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/clang/test/OpenMP/bug69085.c b/clang/test/OpenMP/bug69085.c
index 679d6fb3b092ce..16f0f8b5684f2c 100644
--- a/clang/test/OpenMP/bug69085.c
+++ b/clang/test/OpenMP/bug69085.c
@@ -1,7 +1,10 @@
-// RUN: %clang_cc1 -O0 -fopenmp-simd %s
+// RUN: %clang_cc1 -verify -O0 -fopenmp-simd %s
-int k[-46];
+int k[-1]; // expected-error {{'k' declared as an array with a negative size}}
void foo() {
-#pragma omp task depend(inout: k [0.5:])
-}
+ #pragma omp task depend(inout: k [:])
+ {
+ k[0] = 1;
+ }
+}
\ No newline at end of file
>From 10ada7f5a8929ea7726c4805f24d3829dbbcb7d5 Mon Sep 17 00:00:00 2001
From: Sh0g0-1758 <shouryagoel10000 at gmail.com>
Date: Wed, 7 Feb 2024 23:02:45 +0530
Subject: [PATCH 4/4] Added new line
---
clang/test/OpenMP/bug69085.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/clang/test/OpenMP/bug69085.c b/clang/test/OpenMP/bug69085.c
index 16f0f8b5684f2c..1017ea53b41e3d 100644
--- a/clang/test/OpenMP/bug69085.c
+++ b/clang/test/OpenMP/bug69085.c
@@ -7,4 +7,4 @@ void foo() {
{
k[0] = 1;
}
-}
\ No newline at end of file
+}
More information about the cfe-commits
mailing list