[clang] [Clang][OpenMP] Fix `!isNull() && "Cannot retrieve a NULL type pointer"' fail. (PR #81015)
Joseph Huber via cfe-commits
cfe-commits at lists.llvm.org
Wed Feb 7 11:10:42 PST 2024
https://github.com/jhuber6 updated https://github.com/llvm/llvm-project/pull/81015
>From ed6b669d7d427f2cb4d87f9d4a8063e1b919fc03 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/5] 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 1556f6e854613..1f73fe6f8742e 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 af7a1687a8dda01207236ccdcf745842c1a048de 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/5] 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 0000000000000..679d6fb3b092c
--- /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 c18c9bc5f1ebaf02ac9cf60a218fd3c6d36f9c1e 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/5] 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 679d6fb3b092c..16f0f8b5684f2 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 dfd1eab51f6feed67e37d8353322d2059b88a13a 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/5] 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 16f0f8b5684f2..1017ea53b41e3 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
+}
>From 5c5577ee78214d3c2a07e784af1f7518721e43b7 Mon Sep 17 00:00:00 2001
From: Sh0g0-1758 <shouryagoel10000 at gmail.com>
Date: Wed, 7 Feb 2024 23:24:15 +0530
Subject: [PATCH 5/5] Returning Null Ptr
---
clang/lib/Sema/SemaOpenMP.cpp | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp
index 1f73fe6f8742e..7f75cfc5b54f3 100644
--- a/clang/lib/Sema/SemaOpenMP.cpp
+++ b/clang/lib/Sema/SemaOpenMP.cpp
@@ -21124,8 +21124,8 @@ Sema::ActOnOpenMPDependClause(const OMPDependClause::DependDataTy &Data,
ExprTy = ATy->getElementType();
else
ExprTy = BaseType->getPointeeType();
- if (ExprTy.isNull())
- continue;
+ if (BaseType.isNull() || ExprTy.isNull())
+ return nullptr;
ExprTy = ExprTy.getNonReferenceType();
const Expr *Length = OASE->getLength();
Expr::EvalResult Result;
More information about the cfe-commits
mailing list