[clang] [Clang][OpenMP] throw compilation error instead of crash in Stmt::OMPScopeDirectiveClass case (#77535) (PR #84135)
via cfe-commits
cfe-commits at lists.llvm.org
Wed Mar 6 17:00:01 PST 2024
https://github.com/Puellaquae updated https://github.com/llvm/llvm-project/pull/84135
>From a2c88b0b615875d625b49e596886a0f5b32cf159 Mon Sep 17 00:00:00 2001
From: Puellaquae <shentukeqin at hotmail.com>
Date: Wed, 6 Mar 2024 05:22:08 +0000
Subject: [PATCH 1/3] [Clang][OpenMP] throw compilation error instead of crash
in Stmt::OMPScopeDirectiveClass case (#77535)
---
clang/lib/CodeGen/CGStmt.cpp | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/clang/lib/CodeGen/CGStmt.cpp b/clang/lib/CodeGen/CGStmt.cpp
index d0a3a716ad75e1..698986a3e49dd0 100644
--- a/clang/lib/CodeGen/CGStmt.cpp
+++ b/clang/lib/CodeGen/CGStmt.cpp
@@ -414,7 +414,8 @@ void CodeGenFunction::EmitStmt(const Stmt *S, ArrayRef<const Attr *> Attrs) {
CGM.ErrorUnsupported(S, "OpenMP dispatch directive");
break;
case Stmt::OMPScopeDirectiveClass:
- llvm_unreachable("scope not supported with FE outlining");
+ CGM.ErrorUnsupported(S, "scope with FE outlining");
+ break;
case Stmt::OMPMaskedDirectiveClass:
EmitOMPMaskedDirective(cast<OMPMaskedDirective>(*S));
break;
>From 52e4f0b996085b289d1550af06760e273c390996 Mon Sep 17 00:00:00 2001
From: Puellaquae <shentukeqin at hotmail.com>
Date: Wed, 6 Mar 2024 08:05:52 +0000
Subject: [PATCH 2/3] [Clang][OpenMP] add test for Stmt::OMPScopeDirectiveClass
support error
---
clang/test/OpenMP/error_unsupport_feature.c | 8 ++++++++
1 file changed, 8 insertions(+)
create mode 100644 clang/test/OpenMP/error_unsupport_feature.c
diff --git a/clang/test/OpenMP/error_unsupport_feature.c b/clang/test/OpenMP/error_unsupport_feature.c
new file mode 100644
index 00000000000000..a100300752db91
--- /dev/null
+++ b/clang/test/OpenMP/error_unsupport_feature.c
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -emit-obj -verify -fopenmp %s
+
+int main () {
+ int r = 0;
+#pragma omp scope reduction(+:r) // expected-error {{cannot compile this scope with FE outlining yet}}
+ r++;
+ return r;
+}
>From 7f3ac8e792d5070369bc008e3dc0e470d34c6974 Mon Sep 17 00:00:00 2001
From: Puellaquae <shentukeqin at hotmail.com>
Date: Thu, 7 Mar 2024 00:59:39 +0000
Subject: [PATCH 3/3] [Test] use emit-llvm in test
---
clang/test/OpenMP/error_unsupport_feature.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/clang/test/OpenMP/error_unsupport_feature.c b/clang/test/OpenMP/error_unsupport_feature.c
index a100300752db91..611a8b4639c44e 100644
--- a/clang/test/OpenMP/error_unsupport_feature.c
+++ b/clang/test/OpenMP/error_unsupport_feature.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -emit-obj -verify -fopenmp %s
+// RUN: %clang_cc1 -emit-llvm -verify -fopenmp %s
int main () {
int r = 0;
More information about the cfe-commits
mailing list