Skip to content

Commit 85b2e9c

Browse files
authored
[Clang][OpenMP] Emit unsupported directive error (llvm#70233)
Hello! This PR fixes llvm#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. ```
1 parent b86420c commit 85b2e9c

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

clang/lib/CodeGen/CGStmt.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,7 @@ void CodeGenFunction::EmitStmt(const Stmt *S, ArrayRef<const Attr *> Attrs) {
407407
EmitOMPInteropDirective(cast<OMPInteropDirective>(*S));
408408
break;
409409
case Stmt::OMPDispatchDirectiveClass:
410-
llvm_unreachable("Dispatch directive not supported yet.");
410+
CGM.ErrorUnsupported(S, "OpenMP dispatch directive");
411411
break;
412412
case Stmt::OMPScopeDirectiveClass:
413413
llvm_unreachable("scope not supported with FE outlining");
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// RUN: %clang_cc1 -emit-llvm -fopenmp -disable-llvm-passes %s -verify=expected
2+
3+
// expected-error@+2 {{cannot compile this OpenMP dispatch directive yet}}
4+
void a(){
5+
#pragma omp dispatch
6+
a();
7+
}

0 commit comments

Comments
 (0)