llvmbot wrote:

<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clang

Author: Krzysztof Parzyszek (kparzysz)

<details>
<summary>Changes</summary>

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

---
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
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}}
+}
+

``````````

</details>


https://github.com/llvm/llvm-project/pull/139793
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to