Issue 243150
Summary [flang] Dummy procedure declared by an interface body is accepted in an ELEMENTAL subprogram (C15118)
Labels flang
Assignees
Reporter eugeneepshteyn
    flang accepts this without a diagnostic:

```fortran
elemental subroutine es(f)
  interface
    pure subroutine f()
    end subroutine
  end interface
end subroutine
```

F2023 C15118 requires every dummy argument of an elemental procedure to be a dummy data object, so the dummy procedure `f` is not allowed. gfortran rejects it.

Declared with a procedure declaration statement instead, the same dummy is diagnosed:

```fortran
elemental subroutine es(f)
  procedure() :: f
end subroutine
```

```
error: An ELEMENTAL subprogram may not have a dummy procedure
```

That check (`// C15100`, the F2018 number) is in `CheckHelper::CheckProcEntity` in `flang/lib/Semantics/check-declarations.cpp`, so it runs only for a dummy with `ProcEntityDetails`. A dummy procedure declared by an interface body has `SubprogramDetails` and never reaches it. Issue 229220 is the same gap for INTENT (C845), which PR 240042 addresses by moving that check into `CheckHelper::Check(const Symbol &)`.

Seen with flang built from main at 2f6c791287848c44fbfd85e724fd4f8728aad7d4.

(This issue was filed with the help of AI)

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

Reply via email to