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

    <tr>
        <th>Summary</th>
        <td>
            [flang][Semantics] Flang is unable to `use` a module it compiled
        </td>
    </tr>

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

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

    <tr>
      <th>Reporter</th>
      <td>
          inaki-amatria
      </td>
    </tr>
</table>

<pre>
    - `flang-new` version is: `flang-new version 20.0.0git (https://github.com/llvm/llvm-project.git bafe3a4b0ca0e9294a18a9ec4fea8567cb98dabe)`
- Reduced test case:
```f90
! foo.f90
module foo
  use iso_c_binding, only : c_ptr, c_null_ptr

  implicit none

  private
  public :: foo_t

  type :: foo_t
    real(kind=4), dimension(:), contiguous, pointer :: buffer => null()
    type(c_ptr) :: c_ptr = c_null_ptr
  end type foo_t
contains
end module foo

! bar.f90
module bar
 use foo, only : foo_t

  implicit none

  private
  public :: bar_t

  type :: bar_t
    type(foo_t) :: buffer = foo_t()
  end type bar_t
end module bar

! main.f90
program main
  use bar
end program main
```
- `flang-new` invocation is: `flang-new foo.f90 bar.f90 main.f90`
- Expected behavior is: The code compiles successfully without errors.
- Actual behavior: Compilation fails with the following error:
```
bar.mod:9:47: error: Value in structure constructor of type 'REAL(4)' is incompatible with component 'c_ptr' of type 'c_ptr'
 type(foo_t)::buffer=foo_t(buffer=NULL(),c_ptr=c_ptr(__address=0_8))
 ^^^^^^^^^^^^^^^^^^^^
foo.mod:12:14: Declaration of 'c_ptr'
 type(c_ptr)::c_ptr=__builtin_c_ptr(__address=0_8)
 ^^^^^
bar.mod:9:53: error: Keyword '__address=' may not appear in a reference to a procedure with an implicit interface
 type(foo_t)::buffer=foo_t(buffer=NULL(),c_ptr=c_ptr(__address=0_8))
 ^^^^^^^^^
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzMVkmP4zg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