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

[Flang] Missing diagnose on multiple proc-decl when Binding NAME= is present

Open DanielCChen opened this issue 2 years ago • 4 comments

Consider the following code:

   interface
      subroutine foo() BIND(C)
      end subroutine
   end interface

   procedure(foo), BIND(C, NAME='myfptr') :: p1, p2, p3
   end

Flang currently compiles it successfully, but it violates the following constraint

C1520 (R1512) If proc-language-binding-spec with NAME= is specified, then proc-decl-list shall contain exactly
21 one proc-decl, which shall neither have the POINTER attribute nor be a dummy procedure.

DanielCChen avatar Feb 21 '24 20:02 DanielCChen

@llvm/issue-subscribers-bug

Author: Daniel Chen (DanielCChen)

Consider the following code: ``` interface subroutine foo() BIND(C) end subroutine end interface

procedure(foo), BIND(C, NAME='myfptr') :: p1, p2, p3 end

Flang currently compiles it successfully, but it violates the following constraint 

C1520 (R1512) If proc-language-binding-spec with NAME= is specified, then proc-decl-list shall contain exactly 21 one proc-decl, which shall neither have the POINTER attribute nor be a dummy procedure.

</details>

llvmbot avatar Feb 21 '24 20:02 llvmbot

@llvm/issue-subscribers-flang-frontend

Author: Daniel Chen (DanielCChen)

Consider the following code: ``` interface subroutine foo() BIND(C) end subroutine end interface

procedure(foo), BIND(C, NAME='myfptr') :: p1, p2, p3 end

Flang currently compiles it successfully, but it violates the following constraint 

C1520 (R1512) If proc-language-binding-spec with NAME= is specified, then proc-decl-list shall contain exactly 21 one proc-decl, which shall neither have the POINTER attribute nor be a dummy procedure.

</details>

llvmbot avatar Feb 21 '24 20:02 llvmbot

https://github.com/llvm/llvm-project/pull/82842

klausler avatar Feb 23 '24 23:02 klausler

I have verified PR #82842 fixed the issue. Flang now issues

A procedure declaration statement with a binding name may not declare multiple procedures
     procedure(foo), BIND(C, NAME='myfptr') :: p1, p2, p3
     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Thanks for the quick fix! @klausler

DanielCChen avatar Feb 27 '24 16:02 DanielCChen