<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/115010>115010</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            [flang] Incorrect Error for `bind(c)` procedure
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            flang
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          everythingfunctional
      </td>
    </tr>
</table>

<pre>
    When compiling something like the following example code:

```fortran
program main
    implicit none

    type :: a
        integer, pointer :: b
    end type
contains
 subroutine sub(x) bind(c)
        type(a), pointer, intent(in) :: x
 end subroutine
end program
```

flang reports an error like the following:

```text
error: Semantic errors in example.f90
./example.f90:9:41: error: The derived type of an interoperable object must be interoperable, but is not
          type(a), pointer, intent(in) :: x
 ^
./example.f90:4:13: Non-interoperable type
      type :: a
 ^
./example.f90:5:29: An interoperable derived type cannot have a pointer or allocatable component
          integer, pointer :: b
```

However this is incorrect based on the following excerpt from the standard:

> 18.3.7 Interoperability of procedures and procedure interfaces
> ...
> A Fortran procedure interface is interoperable with a C function prototype if
> ...
> (5) any dummy argument without the VALUE attribute corresponds to a formal parameter of the prototype that is of a pointer type, and either
> ... *  the dummy argument is ... a pointer without the CONTIGUOUS attribute, and the formal parameter is a pointer to CFI_cdesc_t
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJycVcFu4zYQ_Rr6MoggUZYjH3Rwk7gNUOwedtMeF5Q0sthSHIEcJfHfF6ScyHaTFlggiKUh583jm8eR8l4fLGIlil9Ecb9SE_fkKnxGd-Re20M32YY1WWVWNbXH6s8eLTQ0jNpoewBPA8Z9YPTfCNwjdGQMvYQQvqphNAgNtSjynUjvRfr2f5POfx05dsrO0dHRwakBBqVPEQAAPYxGN5rBksVzkLDIxxEhgOc7UEs45lnGAzoh72Ck8OLeNtbLRrRtxJgjDVlW2vrTup9qRxNri-FRyPJVyC3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