[all-commits] [llvm/llvm-project] f7c908: [flang][OpenMP] Check DEFAULT(NONE) on metadirecti...

Chi-Chun, Chen via All-commits all-commits at lists.llvm.org
Fri Jul 24 09:34:15 PDT 2026


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: f7c908b048fe8637fea7346cae808df38075b018
      https://github.com/llvm/llvm-project/commit/f7c908b048fe8637fea7346cae808df38075b018
  Author: Chi-Chun, Chen <chichun.chen at hpe.com>
  Date:   2026-07-24 (Fri, 24 Jul 2026)

  Changed paths:
    M flang/lib/Semantics/check-omp-structure.h
    M flang/lib/Semantics/check-omp-variant.cpp
    A flang/test/Semantics/OpenMP/metadirective-default-none.f90

  Log Message:
  -----------
  [flang][OpenMP] Check DEFAULT(NONE) on metadirective loop variants (#210172)

Flang does not enforce `DEFAULT(NONE)` for variables referenced in a
loop
associated with a standalone METADIRECTIVE. Consequently, it accepts
invalid
programs when a potentially selectable loop variant specifies
DEFAULT(NONE) but
omits a referenced variable from its data-sharing clauses. This change
checks the
associated loop for each potentially selectable `DEFAULT(NONE)` variant
and
diagnoses missing data-sharing attributes as it does for ordinary OpenMP
loop
constructs.

Standalone metadirectives and their associated loops are separate
parse-tree
nodes. For example:

```fortran
!$omp metadirective &
!$omp& when(implementation={vendor(llvm)}: &
!$omp& parallel do default(none) shared(n, a)) default(nothing)
do i = 1, n
  a(i) = x
end do
```

Unlike an ordinary `PARALLEL DO`, the loop is not nested under the
directive:

```text
METADIRECTIVE
`-- WHEN
    `-- PARALLEL DO DEFAULT(NONE) SHARED(n, a)

DO
`-- a(i) = x
```

Name resolution therefore leaves the variant context before visiting the
loop and
does not diagnose the missing data-sharing attribute for `x`.

After associating a metadirective with its loop, validate DEFAULT(NONE)
for each
potentially selectable loop variant. Preserve the existing rules for
predetermined and explicit data-sharing attributes, static locals,
nested
constructs, specification expressions, and statically inapplicable
variants.

Assisted with codex.



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list