Issue 106019
Summary [Flang] Compilation error when an array is entity-name in bind statement and use-name in rename statement
Labels flang:frontend
Assignees
Reporter ohno-fj
    ```
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
$
```

_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to