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

    <tr>
        <th>Summary</th>
        <td>
            [Flang] Compilation error when an array is entity-name in bind statement and use-name in rename statement
        </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 : 20.0.0(3496245ed3d0b4d24444260da77dcdb93512fb5a/AArch64
```

When an array is `entity-name` in `bind` statement and `use-name` in `rename` statement, a compilation error occurs.  
When `bind` statement in module (m11) is moved after `dimension` statement, the compilation succeeds.  
The fixed program is `snggy579_21.f90`.

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

snggy579_2.f90:
```fortran
module m1
  integer:: x1
  integer,parameter::z=10000
  dimension x1(z)
  bind(c,name='xx1') :: x1
contains
  subroutine m1p
    x1=10
  end subroutine m1p
end module m1

module m11
  use m1,only:y1=>x1
  integer,private:: x1
  bind(c,name='xx3') :: x1
  dimension x1(10000)
contains
  subroutine m11p
    x1=110
  end subroutine m11p
end module m11

program main
  use m1
  use m11
  call m1p
  call m11p
  print *,'pass'
end program main
```

```
$ flang-new snggy579_2.f90
error: Semantic errors in snggy579_2.f90
./snggy579_2.f90:14:21: error: The entity 'x1' has multiple BIND names ('xx3' and 'x1')
    integer,private:: x1
                      ^^
$
```

```
$ gfortran snggy579_2.f90; ./a.out
snggy579_2.f90:14:22:

   14 |   integer,private:: x1
      |                      1
Warning: Symbol â€˜x1’ at (1) is marked PRIVATE but has been given the binding label â€˜xx3’
 pass
$
```

```
$ ifort -diag-disable=10448 snggy579_2.f90
snggy579_2.f90: error #7556: The external name for this symbol conflicts with a previously declared external name.   [Y1]
compilation aborted for snggy579_2.f90 (code 1)
$
```

snggy579_21.f90:
```fortran
module m1
  integer:: x1
  integer,parameter::z=10000
  dimension x1(z)
  bind(c,name='xx1') :: x1
contains
  subroutine m1p
    x1=10
  end subroutine m1p
end module m1

module m11
  use m1,only:y1=>x1
  integer,private:: x1
  dimension x1(10000)
  bind(c,name='xx3') :: x1
contains
  subroutine m11p
    x1=110
  end subroutine m11p
end module m11

program main
  use m1
  use m11
  call m1p
  call m11p
  print *,'pass'
end program main
```

```
$ flang-new snggy579_21.f90; ./a.out
 pass
$
```

</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzsV02P4jgT_jXmUgIllQTIgQMNzau5vFrtjma0p5UTV4JnHRvZTjfMr185IUAHptWzl70MQt3YKdfHU-WnUtw5WWuiFcueWLad8NbvjV2ZvTbT6tukMOK0YvPo_I22LFp_Ieuk0WAqqBTX9VTTK7BkDRjNolnEcJmk-RzTjEQioiIVmKZpivNI8MVClKLIkyzGqsg4w916bcv9PO01jwz1f7_uSQPXwK3lJ5AO2Dwi7aU_TTVviM0jkDpsFlKLsHKee2pIe-BahAeto5GopWF9EWa4AQ6laQ5ScR_iI2uNBVOWrXUzgBtvHhqTGhojWkXAcNnEMcM8eNuYFxLAK082nBOyIR3guzPu9_TGvGvLkkhcTX_eE1TySAIO1tSWN2cwnK7rU7bI_8J4VuUBvtktft0xo5R5lboGbqmz5Mn5QU-wvhsyGRb_q4z1NmCuBciwuPWM4Y6OVLadl5Zcq_wbg1d_OneS9Si5Z-X97hmyJu6XAFJ7qsmGY8kajnf7uDlwyxvyg8x3lmzjKIqiQfICcTiNy-8M8-FRlzVclgw3XQEkW4aLYxBbhHSNjJZGey61G067trCm9VIHfw_DLgT54MKwQVo8FA37o3BHGFyCbV0ngxuj1Ykl61OwwJLnh3BY-cI93QH2g1iTx7HewdZDOkD3LhT3WLwDxkM03sAxVHfDpR4B8mZ1WZZcqduMnNfXjYOV2gPDNcMNw8WBOxdQuPhxb_EhE403Mb0hwFHV97oDgwSU_6CGay_LnlNc4IpH8jOGu7vbE6csWW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