Issue 115010
Summary [flang] Incorrect Error for `bind(c)` procedure
Labels flang
Assignees
Reporter everythingfunctional
    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
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to