Issue 171951
Summary [Flang] Incorrect compile error when RECURSIVE is not required in Flang 22.0.0
Labels flang
Assignees
Reporter 3776-u2
    ```
Version of flang 22.0.0git (8378a6fa4f5c83298fb0b5e240bb7f254f7b1137)/AArch64
```
The attached program (`sample.f90`) results in an error when compiled with Flang version 22.0.0. However, according to Fortran 2023 standard 15.6.2.1, the `RECURSIVE` attribute is only required for procedures that directly or indirectly invoke themselves. Since this program does not involve such an invocation, it should not produce an error.

sample.f90
```fortran
function ifunc() result(irst)
  procedure(ifunc), pointer :: irst
end function
```
```
$ /work/groups/ssoft/compiler/llvm/aarch64/main-latest/bin/flang --version
flang version 22.0.0git (https://github.com/llvm/llvm-project.git 8378a6fa4f5c83298fb0b5e240bb7f254f7b1137)
Target: aarch64-unknown-linux-gnu
Thread model: posix
InstalledDir: /work/groups/ssoft/compiler/llvm/aarch64/main-20251201-f42e58f61680/bin
Build config: +assertions
$ /work/groups/ssoft/compiler/llvm/aarch64/main-latest/bin/flang sample.f90
error: Semantic errors in sample.f90
./sample.f90:1:10: error: Procedure 'ifunc' is recursively defined. Procedures in the cycle: 'ifunc', 'irst'
  function ifunc() result(irst)
           ^^^^^
./sample.f90:2:32: error: Procedure 'irst' is recursively defined. Procedures in the cycle: 'ifunc', 'irst'
    procedure(ifunc), pointer :: irst
 ^^^^
$
```
```
$ ifx --version
ifx (IFX) 2024.2.1 20240711
Copyright (C) 1985-2024 Intel Corporation. All rights reserved.

$ ifx sample.f90 -c
sample.f90(2): warning #6178: The return value of this FUNCTION has not been defined. [IRST]
  procedure(ifunc), pointer :: irst
-------------------------------^
$
```
```
$ gfortran sample.f90 -c
$
```
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to