Repository: llvm/llvm-project

Issue:
[flang][OpenMP] Incorrect signature for omp_get_cancellation()
Currently, `omp_get_cancellation()` is declared like this in openmp/runtime/src/include/omp_lib.F90.var:
```
 400           function omp_get_cancellation() bind(c)
 401             use omp_lib_kinds
 402             integer (kind=omp_integer_kind) omp_get_cancellation
 403           end function omp_get_cancellation
```
In OpenMP 5.2 spec, Fortran declaration for this function is as follows:
```
logical function omp_get_cancellation()
```
The return type difference prevents using `omp_get_cancellation()` in logical expressions:
```
use omp_lib
logical :: flag = .TRUE. 
flag = flag .and. omp_get_cancellation()
end
```
Error:
```
$ flang -c -fopenmp cancellation.f90 
flang-21: warning: OpenMP support in flang is still experimental [-Wexperimental-option]
error: Semantic errors in cancellation.f90
./cancellation.f90:3:8: error: Operands of .AND. must be LOGICAL; have LOGICAL(4) and INTEGER(4)
  flag = flag .and. omp_get_cancellation()
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
```
flang version:
```
$ flang --version
flang version 21.0.0git (https://github.com/eugeneepshteyn/llvm-project.git cf348e886d0b30a4bf3e810efc00b2da0f7a4322)
Target: x86_64-unknown-linux-gnu
Thread model: posix
...
```


Discussion:

Patch:
diff --git a/openmp/runtime/src/include/omp_lib.F90.var b/openmp/runtime/src/include/omp_lib.F90.var
index 3463b698291e1..20639f60b5d97 100644
--- a/openmp/runtime/src/include/omp_lib.F90.var
+++ b/openmp/runtime/src/include/omp_lib.F90.var
@@ -399,7 +399,7 @@
 
           function omp_get_cancellation() bind(c)
             use omp_lib_kinds
-            integer (kind=omp_integer_kind) omp_get_cancellation
+            logical (kind=omp_logical_kind) omp_get_cancellation
           end function omp_get_cancellation
 
           function omp_is_initial_device() bind(c)