llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
29.14k stars 12.02k forks source link

[Flang] Compilation error when proc-decl is defined using sub for proc-pointer-init in recursive subroutine #116566

Open ohno-fj opened 3 hours ago

ohno-fj commented 3 hours ago
Version of flang-new : 20.0.0(7111d031f19ce7d523796b4812d6afcb2958b025)/AArch64

When proc-decl is defined using sub for proc-pointer-init in recursive subroutine (sub), a compilation error occurs.

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

snf_pointer_ivl_007_2.f90:

recursive subroutine sub()
  procedure(sub),pointer :: p=>sub
  p=>sub
end subroutine sub

program main
  print *,'pass'
end program main
$ flang-new snf_pointer_ivl_007_2.f90
error: Semantic errors in snf_pointer_ivl_007_2.f90
./snf_pointer_ivl_007_2.f90:2:29: error: Procedure pointer 'p' initializer 'sub' is neither an external nor a module procedure
    procedure(sub),pointer :: p=>sub
                              ^
$
$ gfortran snf_pointer_ivl_007_2.f90; ./a.out
 pass
$
$ ifx snf_pointer_ivl_007_2.f90; ./a.out
 pass
$
llvmbot commented 3 hours ago

@llvm/issue-subscribers-flang-frontend

Author: None (ohno-fj)

``` Version of flang-new : 20.0.0(7111d031f19ce7d523796b4812d6afcb2958b025)/AArch64 ``` When `proc-decl` is defined using `sub` for `proc-pointer-init` in `recursive subroutine (sub)`, a compilation error occurs. The following are the test program, Flang-new, Gfortran and ifx compilation/execution result. snf_pointer_ivl_007_2.f90: ```fortran recursive subroutine sub() procedure(sub),pointer :: p=>sub p=>sub end subroutine sub program main print *,'pass' end program main ``` ``` $ flang-new snf_pointer_ivl_007_2.f90 error: Semantic errors in snf_pointer_ivl_007_2.f90 ./snf_pointer_ivl_007_2.f90:2:29: error: Procedure pointer 'p' initializer 'sub' is neither an external nor a module procedure procedure(sub),pointer :: p=>sub ^ $ ``` ``` $ gfortran snf_pointer_ivl_007_2.f90; ./a.out pass $ ``` ``` $ ifx snf_pointer_ivl_007_2.f90; ./a.out pass $ ```