Issue 71367
Summary [Flang] Compilation error when the same subroutine name but different arugment types
Labels flang:frontend
Assignees
Reporter ohno-fj
    ```
Version of flang-new : 18.0.0(1c876ff5155c4feeb2b2885eb3e6abda17c4b7f4)
```

A compilation error occurs if `subroutine` with the same name is declared in `interface` and `subroutine` statements but their argument types are not the same.  
When I specify `-flang-experimental-hlfir` at the compilation, I can avoid the compilation error.


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

gc_e157_2.f90:
```fortran
program main
  interface
     subroutine sub(a)
       integer,dimension(3):: a
     end subroutine sub
  end interface

  integer,dimension(3):: a
  call sub(a)
end program main

subroutine sub(s)
  integer,dimension(:):: s
end subroutine sub
```

```
$ flang-new gc_e157_2.f90
./gc_e157_2.f90:3:17: warning: The global subprogram 'sub' is not compatible with its local procedure declaration (incompatible dummy argument #1: incompatible dummy data object attributes)
       subroutine sub(a)
                  ^^^
./gc_e157_2.f90:12:12: Declaration of 'sub'
  subroutine sub(s)
             ^^^
./gc_e157_2.f90:3:17: Declaration of 'sub'
       subroutine sub(a)
                  ^^^
error: loc("/work/home/ohno/CT/test/fort/tp/reproducer/Metro/gc_err/gc_e157_2.f90":9:3): 'fir.convert' op invalid type conversion
error: verification of lowering to FIR failed

$
```

```
$ flang-new gc_e157_2.f90 -flang-experimental-hlfir
./gc_e157_2.f90:3:17: warning: The global subprogram 'sub' is not compatible with its local procedure declaration (incompatible dummy argument #1: incompatible dummy data object attributes)
       subroutine sub(a)
                  ^^^
./gc_e157_2.f90:12:12: Declaration of 'sub'
  subroutine sub(s)
             ^^^
./gc_e157_2.f90:3:17: Declaration of 'sub'
       subroutine sub(a)
                  ^^^
```

```
$ gfortran gc_e157_2.f90
gc_e157_2.f90:3:19:

    3 |      subroutine sub(a)
      |                   1
Warning: Interface mismatch in global procedure ‘sub’ at (1): Shape mismatch in argument 'a'
$
```

```
$ ifort gc_e157_2.f90
$
```
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to