Skip to content

[Flang] Compilation error when the name of procedure-entity-name in procedure declaration statement are the same as generic-name specified in INTERFACE statement #107784

@ohno-fj

Description

@ohno-fj
Version of flang-new : 20.0.0(357bd61744bb8cc2b9b07447294fa977e5758550/AArch64

When the name of procedure-entity-name in procedure declaration statement is the same as generic-name specified in INTERFACE statement, a compilation-time error occurs.

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

snggx416_.f90:

module m1
  interface
     integer function ext(dmy)
       integer :: dmy
     end function ext
  end interface
  procedure(ext),pointer :: gnr
  interface gnr
     procedure :: gnr
  end interface gnr
end module m1

program main
  use m1
  gnr=> ext
  if (gnr(1)/=1) print *,101,gnr(1)
  if (ext(1)/=1) print *,102,ext(1)
  print *,'pass'
end program main

integer function ext(dmy)
  integer :: dmy
  ext=dmy
end function ext
$ flang-new snggx416_.f90
error: Semantic errors in snggx416_.f90
./snggx416_.f90:8:13: error: 'gnr' is already declared in this scoping unit
    interface gnr
              ^^^
./snggx416_.f90:7:29: Previous declaration of 'gnr'
    procedure(ext),pointer :: gnr
                              ^^^
./snggx416_.f90:15:3: error: 'gnr' is not a specific procedure
    gnr=> ext
    ^^^
./snggx416_.f90:16:7: error: Cannot call subroutine 'gnr' like a function
    if (gnr(1)/=1) print *,101,gnr(1)
        ^^^
./snggx416_.f90:7:29: Declaration of 'gnr'
    procedure(ext),pointer :: gnr
                              ^^^
./snggx416_.f90:16:7: error: No specific function of generic 'gnr' matches the actual arguments
    if (gnr(1)/=1) print *,101,gnr(1)
        ^^^^^^
./snggx416_.f90:16:30: error: Cannot call subroutine 'gnr' like a function
    if (gnr(1)/=1) print *,101,gnr(1)
                               ^^^
./snggx416_.f90:7:29: Declaration of 'gnr'
    procedure(ext),pointer :: gnr
                              ^^^
./snggx416_.f90:16:30: error: No specific function of generic 'gnr' matches the actual arguments
    if (gnr(1)/=1) print *,101,gnr(1)
                               ^^^^^^
$
$ gfortran snggx416_.f90; ./a.out
 pass
$
$ ifort -diag-disable=10448 snggx416_.f90; ./a.out
 pass
$

Metadata

Metadata

Assignees

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions