llvm-project icon indicating copy to clipboard operation
llvm-project copied to clipboard

[Flang] Flang incorrectly accepts keyword arguments in calls to statement functions

Open blazie2004 opened this issue 6 months ago • 4 comments

Flang fails to diagnose keyword arguments in calls to statement functions. Keyword arguments are only valid when the interface is explicit. Flang silently accepts keyword arguments in calls to procedures with implicit interfaces.

Standard: F2018 §15.5.1 C1535: "In a reference to a procedure whose interface is implicit at the point of the reference, the actual argument shall not be a keyword argument."

Reproducer

program test
  integer :: f1, x, c
  f1(x) = x / 2
  c = f1(x=10)  ! Should be an error
end program

Expected Behavior

error: Keyword 'x=' may not appear in a reference to a procedure with an implicit interface

Actual behavior:

Silently accepts the code

blazie2004 avatar May 19 '26 13:05 blazie2004

NAG, gfortran 16.1, ifx, nvfortran all reject this with an error.

eugeneepshteyn avatar May 19 '26 17:05 eugeneepshteyn

@blazie2004 , a request: if you plan to work on an issue, please assign it to yourself (or ask someone to assign it to you). It helps to keep track of which issues are available for others to work on. Thank you!

eugeneepshteyn avatar May 19 '26 20:05 eugeneepshteyn

This was already fixed by the PR mentioned above.

eugeneepshteyn avatar Aug 13 '26 16:08 eugeneepshteyn

@llvm/issue-subscribers-flang-frontend

Author: jay0x (blazie2004)

Flang fails to diagnose keyword arguments in calls to statement functions. Keyword arguments are only valid when the interface is explicit. Flang silently accepts keyword arguments in calls to procedures with implicit interfaces.

Standard: F2018 §15.5.1 C1535: "In a reference to a procedure whose interface is implicit at the point of the reference, the actual argument shall not be a keyword argument."

Reproducer

program test
  integer :: f1, x, c
  f1(x) = x / 2
  c = f1(x=10)  ! Should be an error
end program

Expected Behavior

error: Keyword 'x=' may not appear in a reference to a procedure with an implicit interface

Actual behavior:

Silently accepts the code