Author: Krzysztof Parzyszek
Date: 2025-05-14T07:06:11-05:00
New Revision: 3abd77ac157f87f2fa0c8083b9f27c1dd2896a25

URL: 
https://github.com/llvm/llvm-project/commit/3abd77ac157f87f2fa0c8083b9f27c1dd2896a25
DIFF: 
https://github.com/llvm/llvm-project/commit/3abd77ac157f87f2fa0c8083b9f27c1dd2896a25.diff

LOG: [clang][OpenMP] Treat "workshare" as unknown OpenMP directive (#139793)

The "workshare" construct is only present in Fortran. The common OpenMP
code does treat it as any other directive, but in clang we need to
reject it, and do so gracefully before it encounters an internal
assertion.

Fixes https://github.com/llvm/llvm-project/issues/139424

Added: 
    clang/test/OpenMP/openmp_workshare.c

Modified: 
    clang/lib/Parse/ParseOpenMP.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/Parse/ParseOpenMP.cpp b/clang/lib/Parse/ParseOpenMP.cpp
index 6f64cadc00af5..c409409602e75 100644
--- a/clang/lib/Parse/ParseOpenMP.cpp
+++ b/clang/lib/Parse/ParseOpenMP.cpp
@@ -2613,6 +2613,11 @@ StmtResult 
Parser::ParseOpenMPDeclarativeOrExecutableDirective(
     Diag(Tok, diag::err_omp_unknown_directive);
     return StmtError();
   }
+  if (DKind == OMPD_workshare) {
+    // "workshare" is an executable, Fortran-only directive. Treat it
+    // as unknown.
+    DKind = OMPD_unknown;
+  }
 
   StmtResult Directive = StmtError();
 

diff  --git a/clang/test/OpenMP/openmp_workshare.c 
b/clang/test/OpenMP/openmp_workshare.c
new file mode 100644
index 0000000000000..0302eb19f9ef4
--- /dev/null
+++ b/clang/test/OpenMP/openmp_workshare.c
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -verify -fopenmp -ferror-limit 100 -o - %s
+
+// Workshare is a Fortran-only directive.
+
+void foo() {
+#pragma omp workshare // expected-error {{expected an OpenMP directive}}
+}
+


        
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to