Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[clang][OpenMP] Treat "workshare" as unknown OpenMP directive #139793

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 14, 2025

Conversation

kparzysz
Copy link
Contributor

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 #139424

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 llvm#139424
@llvmbot llvmbot added clang Clang issues not falling into any other category clang:frontend Language frontend issues, e.g. anything involving "Sema" clang:openmp OpenMP related changes to Clang labels May 13, 2025
@llvmbot
Copy link
Member

llvmbot commented May 13, 2025

@llvm/pr-subscribers-clang

Author: Krzysztof Parzyszek (kparzysz)

Changes

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 #139424


Full diff: https://github.com/llvm/llvm-project/pull/139793.diff

2 Files Affected:

  • (modified) clang/lib/Parse/ParseOpenMP.cpp (+5)
  • (added) clang/test/OpenMP/openmp_workshare.c (+8)
diff --git a/clang/lib/Parse/ParseOpenMP.cpp b/clang/lib/Parse/ParseOpenMP.cpp
index 85838feae77d3..2f4a1103cc3b3 100644
--- a/clang/lib/Parse/ParseOpenMP.cpp
+++ b/clang/lib/Parse/ParseOpenMP.cpp
@@ -2738,6 +2738,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}}
+}
+

@kparzysz kparzysz merged commit 3abd77a into llvm:main May 14, 2025
15 checks passed
@kparzysz kparzysz deleted the users/kparzysz/cxx-workshare branch May 14, 2025 12:06
@AaronBallman
Copy link
Collaborator

Thank you for the quick fix!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang:frontend Language frontend issues, e.g. anything involving "Sema" clang:openmp OpenMP related changes to Clang clang Clang issues not falling into any other category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[OpenMP] UNREACHABLE executed at /root/llvm-project/llvm/tools/clang/lib/Basic/OpenMPKinds.cpp:855!
4 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.