Skip to content

[Flang] Incorrect diagnostic on multiple type-bound procedure binding-names point to the same specific procedure-name #124772

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
DanielCChen opened this issue Jan 28, 2025 · 3 comments
Labels
duplicate Resolved as duplicate flang:frontend question A question, not bug report. Check out https://llvm.org/docs/GettingInvolved.html instead!

Comments

@DanielCChen
Copy link
Contributor

Consider the following code:

module m

   type base
      integer :: i = -999
      contains
         procedure, pass(b) :: base1 => base_base_base
         procedure, pass(b) :: base2 => base_base_base
         generic :: operator(+) => base1, base2
   end type

   contains

   type(base) function base_base_base ( a, b )
      class(base), intent(in) :: a
      class(base), intent(in) :: b
   end function

end module

Flang currently issues an error as:

error: Semantic errors in t.f
./t.f:8:21: error: Generic 'OPERATOR(+)' may not have specific procedures 'base%base1' and 'base%base2' as their interfaces are not distinguishable
           generic :: operator(+) => base1, base2
                      ^^^^^^^^^^^
./t.f:13:24: Procedure 'base1' of type 'base' is bound to 'base_base_base'
     type(base) function base_base_base ( a, b )
                         ^^^^^^^^^^^^^^
./t.f:13:24: Procedure 'base2' of type 'base' is bound to 'base_base_base'
     type(base) function base_base_base ( a, b )
                         ^^^^^^^^^^^^^^

The code seems conforming to me as I can't find any wording in the standard prohibit this usage.

Note: This could be a duplicate to issue #124766

@llvmbot
Copy link
Member

llvmbot commented Jan 28, 2025

@llvm/issue-subscribers-flang-frontend

Author: Daniel Chen (DanielCChen)

Consider the following code: ``` module m

type base
integer :: i = -999
contains
procedure, pass(b) :: base1 => base_base_base
procedure, pass(b) :: base2 => base_base_base
generic :: operator(+) => base1, base2
end type

contains

type(base) function base_base_base ( a, b )
class(base), intent(in) :: a
class(base), intent(in) :: b
end function

end module


Flang currently issues an error as:

error: Semantic errors in t.f
./t.f:8:21: error: Generic 'OPERATOR(+)' may not have specific procedures 'base%base1' and 'base%base2' as their interfaces are not distinguishable
generic :: operator(+) => base1, base2
^^^^^^^^^^^
./t.f:13:24: Procedure 'base1' of type 'base' is bound to 'base_base_base'
type(base) function base_base_base ( a, b )
^^^^^^^^^^^^^^
./t.f:13:24: Procedure 'base2' of type 'base' is bound to 'base_base_base'
type(base) function base_base_base ( a, b )
^^^^^^^^^^^^^^


The code seems conforming to me as I can't find any wording in the standard prohibit this usage.

Note: This could be a duplicate to issue #<!-- -->124766 
</details>

@klausler
Copy link
Contributor

It's a duplicate of #124766 and working as intended.

@DanielCChen
Copy link
Contributor Author

Also invalid code as explained in #124766 .

@DanielCChen DanielCChen added the question A question, not bug report. Check out https://llvm.org/docs/GettingInvolved.html instead! label Jan 29, 2025
@EugeneZelenko EugeneZelenko added the duplicate Resolved as duplicate label Jan 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate Resolved as duplicate flang:frontend question A question, not bug report. Check out https://llvm.org/docs/GettingInvolved.html instead!
Projects
None yet
Development

No branches or pull requests

4 participants