Author: Raymond Chang Date: 2023-11-24T16:28:32-05:00 New Revision: 85b2e9c02295a54100d41207cddce5908b8c513f
URL: https://github.com/llvm/llvm-project/commit/85b2e9c02295a54100d41207cddce5908b8c513f DIFF: https://github.com/llvm/llvm-project/commit/85b2e9c02295a54100d41207cddce5908b8c513f.diff LOG: [Clang][OpenMP] Emit unsupported directive error (#70233) Hello! This PR fixes #63871. Clang should no longer crash and instead emits an error message. Below is an example of the new error message: ``` ~/dev/fork-llvm-project omp_dispatch_unimpl ❯ ./install/bin/clang -fopenmp -c -emit-llvm -Xclang -disable-llvm-passes test.c test.c:6:5: error: cannot compile this OpenMP dispatch directive yet 6 | #pragma omp dispatch | ^~~~~~~~~~~~~~~~~~~~ 1 error generated. ``` Added: clang/test/OpenMP/dispatch_unsupported.c Modified: clang/lib/CodeGen/CGStmt.cpp Removed: ################################################################################ diff --git a/clang/lib/CodeGen/CGStmt.cpp b/clang/lib/CodeGen/CGStmt.cpp index a7100c8fae2eff9..a5cb80640641bb2 100644 --- a/clang/lib/CodeGen/CGStmt.cpp +++ b/clang/lib/CodeGen/CGStmt.cpp @@ -407,7 +407,7 @@ void CodeGenFunction::EmitStmt(const Stmt *S, ArrayRef<const Attr *> Attrs) { EmitOMPInteropDirective(cast<OMPInteropDirective>(*S)); break; case Stmt::OMPDispatchDirectiveClass: - llvm_unreachable("Dispatch directive not supported yet."); + CGM.ErrorUnsupported(S, "OpenMP dispatch directive"); break; case Stmt::OMPScopeDirectiveClass: llvm_unreachable("scope not supported with FE outlining"); diff --git a/clang/test/OpenMP/dispatch_unsupported.c b/clang/test/OpenMP/dispatch_unsupported.c new file mode 100644 index 000000000000000..92f555e4b414f4e --- /dev/null +++ b/clang/test/OpenMP/dispatch_unsupported.c @@ -0,0 +1,7 @@ +// RUN: %clang_cc1 -emit-llvm -fopenmp -disable-llvm-passes %s -verify=expected + +// expected-error@+2 {{cannot compile this OpenMP dispatch directive yet}} +void a(){ + #pragma omp dispatch + a(); +} _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits