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

[Flang] GENERIC INTERFACE: BINC(C) attribute not propagate to the generic name that is the same as the specific name that has the BIND(C) attribute.

Open DanielCChen opened this issue 2 years ago • 4 comments

Consider the following code:

  MODULE M
  USE ISO_C_BINDING

  INTERFACE ExtFun
    FUNCTION ExtFun() BIND(C)
    IMPORT
      INTEGER(C_INT) :: ExtFun
    END FUNCTION
  END INTERFACE

  END MODULE

  PROGRAM MAIN
  USE M
  PROCEDURE(ExtFun), BIND(C), POINTER :: PExtFun
  END

Flang currently issues an error as:

: error: An interface name with BIND attribute must be specified if the BIND attribute is specified in a procedure declaration statement
    PROCEDURE(ExtFun), BIND(C), POINTER :: PExtFun
                                           ^^^^^^^

It passes if I remove the generic name. The BIND(C) attribute seems missing from both the generic and specific symbol in the dump.

DanielCChen avatar Feb 19 '24 17:02 DanielCChen

@llvm/issue-subscribers-flang-frontend

Author: Daniel Chen (DanielCChen)

Consider the following code: ``` MODULE M USE ISO_C_BINDING

INTERFACE ExtFun FUNCTION ExtFun() BIND(C) IMPORT INTEGER(C_INT) :: ExtFun END FUNCTION END INTERFACE

END MODULE

PROGRAM MAIN USE M PROCEDURE(ExtFun), BIND(C), POINTER :: PExtFun END


Flang currently issues an error as:

: error: An interface name with BIND attribute must be specified if the BIND attribute is specified in a procedure declaration statement PROCEDURE(ExtFun), BIND(C), POINTER :: PExtFun ^^^^^^^


It passes if I remove the generic name. The `BIND(C)` attribute seems missing from both the generic and specific symbol in the dump.
</details>

llvmbot avatar Feb 19 '24 17:02 llvmbot

@llvm/issue-subscribers-bug

Author: Daniel Chen (DanielCChen)

Consider the following code: ``` MODULE M USE ISO_C_BINDING

INTERFACE ExtFun FUNCTION ExtFun() BIND(C) IMPORT INTEGER(C_INT) :: ExtFun END FUNCTION END INTERFACE

END MODULE

PROGRAM MAIN USE M PROCEDURE(ExtFun), BIND(C), POINTER :: PExtFun END


Flang currently issues an error as:

: error: An interface name with BIND attribute must be specified if the BIND attribute is specified in a procedure declaration statement PROCEDURE(ExtFun), BIND(C), POINTER :: PExtFun ^^^^^^^


It passes if I remove the generic name. The `BIND(C)` attribute seems missing from both the generic and specific symbol in the dump.
</details>

llvmbot avatar Feb 19 '24 17:02 llvmbot

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

klausler avatar Feb 23 '24 22:02 klausler

I have verified PR #82837 has fixed the reproducer and the original test case. Thanks for the quick fix! @klausler

DanielCChen avatar Feb 27 '24 16:02 DanielCChen