Skip to content

[Flang] Regression for BIND(C) Subprograms, Compiler Asserts #116844

@mjklemm

Description

@mjklemm

The following code dies with a compiler assertion, when compiled:

$ flang -c reproducer.f90
reproducer.f90:10:12: warning: Function result is never defined
    function f0(a0, a1) bind(c, name="f0")
             ^^
error: loc("'reproducer.f90":21:5): 'llvm.call' op operand type mismatch for operand 2: 'i64' != '!llvm.ptr'
error: Lowering to LLVM IR failed
Call parameter type does not match function signature!
  %18 = extractvalue { ptr, i64 } %15, 1
 ptr  call void @f0(ptr %4, ptr %17, i64 %18, ptr %6)
error: failed to create the LLVM module

This seem to is caused by commit 367c3c9 and PR #111969.

Reproducer code:

module m
  implicit none

  type, public, bind(c) :: t
    character :: m(256)
  end type t

contains
  function f0(a0, a1) bind(c, name="f0")
    import :: t
    character, intent(in) :: a0(*)
    integer :: a1
    type(t) :: f0
  end function

  function f1() result(v0)
    type(t) :: v0
    character, allocatable, target :: v1(:)
    integer :: v2
    v0 = f0(v1, v2)
  end function

end module

Metadata

Metadata

Assignees

Labels

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions