llvm / llvm/llvm-project

[flang][OpenMP] Non-conforming direct call to a declare-variant function variant accepted silently.

Open
#209,550 1 comment 0 reactions 1 assignee Claimed by @abidh View on GitHub
flang:frontend flang:openmp
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

Flang does not diagnose the OpenMP DECLARE VARIANT restriction that a function variant may not be called directly in an OpenMP context different from its construct selector set.

OpenMP 6.0 section 9.6 (Declare Variant Directives), Restrictions: "Calling procedures that a declare variant directive determined to be a function variant directly in an OpenMP context that is different from the one that the construct selector set of the context selector specifies is non-conforming."

Please see the following program.

```fortran
module m
implicit none
contains
subroutine base()
!$omp declare variant(variant) match(construct={parallel})
end subroutine

subroutine variant()
end subroutine

subroutine caller()
! Non-conforming: 'variant' is specialized for construct={parallel}, but it
! is called directly outside any parallel construct.
call variant()

! For contrast, this direct call is conforming (inside a parallel construct).
!$omp parallel
call variant()
!$omp end parallel
end subroutine
end module
```

This compiles cleanly with flang -fc1 -fopenmp -fsyntax-only. The expectation is that call variant() outside of parallel region should generate an error.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.