[flang-commits] [clang] [flang] [Flang][OpenMP] Add -fopenmp-default-none command line flag (PR #120287)

Michael Klemm via flang-commits flang-commits at lists.llvm.org
Wed Dec 18 08:37:12 PST 2024


================
@@ -2276,7 +2281,8 @@ void OmpAttributeVisitor::Post(const parser::Name &name) {
       if (Symbol * found{currScope().FindSymbol(name.source)}) {
         if (symbol != found) {
           name.symbol = found; // adjust the symbol within region
-        } else if (GetContext().defaultDSA == Symbol::Flag::OmpNone &&
+        } else if ((HaveOpenMPDefaultNone ||
----------------
mjklemm wrote:

This is exactly what this option is supposed to do.  If I misread your comment, please bear with me and explain.  For

```Fortran
subroutine sb1(arr, n)
  integer :: n
  integer :: arr(n)
  !$omp workshare
    arr = n
  !$omp end workshare
end subroutine
```

The `-fopenmp-default-none` acts as if the developer has written this:

```Fortran
subroutine sb1(arr, n)
  integer :: n
  integer :: arr(n)
  !$omp workshare default(none)
    arr = n
  !$omp end workshare
end subroutine
```

So, for both the error would be the same:

```
error: Semantic errors in /net/home/micha/projects/llvm/tmp/datasharing.f90
/net/home/micha/projects/llvm/tmp/datasharing.f90:16:5: error: The DEFAULT(NONE) clause requires that 'arr' must be listed in a data-sharing attribute clause
      arr = n
      ^^^
/net/home/micha/projects/llvm/tmp/datasharing.f90:16:11: error: The DEFAULT(NONE) clause requires that 'n' must be listed in a data-sharing attribute clause
      arr = n
```


















https://github.com/llvm/llvm-project/pull/120287


More information about the flang-commits mailing list