[flang-commits] [flang] [flang] Silence errors on C_LOC/C_FUNLOC in specification expressions (PR #96108)

via flang-commits flang-commits at lists.llvm.org
Thu Jun 20 11:42:29 PDT 2024


================
@@ -82,6 +82,8 @@ auto IsVariableHelper::operator()(const Symbol &symbol) const -> Result {
   const Symbol &ultimate{symbol.GetUltimate()};
   return !IsNamedConstant(ultimate) &&
       (ultimate.has<semantics::ObjectEntityDetails>() ||
+          (ultimate.has<semantics::EntityDetails>() &&
+              ultimate.attrs().test(semantics::Attr::TARGET)) ||
----------------
jeanPerier wrote:

So something like the following will still be rejected with this patch, right?
```
subroutine test(x, y)
 use iso_c_binding, only : c_loc, c_ptr
  interface
    pure integer function purefunc(l)
      import
      type(c_ptr), intent(in) :: l
    end function
  end interface
 integer :: x
 integer :: y(purefunc(c_loc(x)))
 target :: x
end subroutine
```

I think nag, gfortran, ifort, and nvfortran at leat all accept it (all compiler rightfully raise an error if the target statement is removed, except nvfortran).
Maybe that is a corner case that is not worth the complexity though if it has no real useful application though.

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


More information about the flang-commits mailing list