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

    <tr>
        <th>Summary</th>
        <td>
            [Flang] Compilation error when bind statement is specified at the beginning of specification-part in module
        </td>
    </tr>

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

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

    <tr>
      <th>Reporter</th>
      <td>
          ohno-fj
      </td>
    </tr>
</table>

<pre>
    ```
Version of flang-new : 19.0.0(4f19f15a601a5761b12c9c66d99d97dbc89ef90d)/AArch64
```

When `bind` statement is specified at the beginning of `specification-part` in `module`, a compilation error occurs.

However, when `bind` statement is specified at the end of `specification-part` in `module`, a compilation terminates normally.  
The above program (snggq538_22.f90) is attached at the end.

The following are the test program, Flang-new, Gfortran and ifort compilation/execution result.

snggq538_2.f90:
```fortran
module m3
  bind (c,name='y3'):: x3
  integer:: x3
  common /x3/ k
contains
 subroutine z3
    k=1
    x3=2
  end subroutine z3
end module m3

subroutine s1
  use m3
  call z3
end subroutine s1

program main
  call s1
  print *,'pass'
end program main
```

```
$ flang-new snggq538_2.f90
error: Semantic errors in snggq538_2.f90
./snggq538_2.f90:2:24: error: The entity 'x3' has multiple BIND names
    bind (c,name='y3'):: x3
 ^^
./snggq538_2.f90:4:11: error: Two entities have the same global name 'x3'
    common /x3/ k
            ^^
./snggq538_2.f90:3:13: Conflicting declaration
    integer:: x3
 ^^
$
```

```
$ gfortran snggq538_2.f90; ./a.out
 pass
$
```

```
$ ifort -diag-disable=10448 snggq538_2.f90; ./a.out
 pass
$
```

snggq538_22.f90:
```fortran
module m3
  integer:: x3
  common /x3/ k
  bind (c,name='y3'):: x3
contains
  subroutine z3
    k=1
    x3=2
  end subroutine z3
end module m3

subroutine s1
  use m3
  call z3
end subroutine s1

program main
  call s1
  print *,'pass'
end program main
```

```
$ flang-new snggq538_22.f90
$
```

</pre>
<img width="1px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