Issue 122764
Summary [Flang] Incorrect diagnostic on renaming generic operator
Labels flang:frontend
Assignees
Reporter DanielCChen
    Consider the following code:
```
module opmod

  type modreal
    real :: x

 contains
      procedure :: plus
      procedure :: plus2
      generic, private :: operator(.add.) => plus

  end type

  interface operator(.adda.)
    module procedure plus2
  end interface

  contains
 function plus(a,b)
      type(modreal) :: plus
      class(modreal), intent(in) :: a,b
      plus%x = a%x+b%x*2.0
    end function plus

 function plus2(a,b)
      type(modreal) :: plus2
      class(modreal), intent(in) :: a,b
      plus2%x = a%x+b%x
    end function plus2


end module


program main
use opmod , operator(.add.) => operator(.adda.)
end program
```

Flang currently issues an error as:
```
t.f:35:22: error: Generic 'OPERATOR(.add.)' may not have specific procedures 'plus2' and 'modreal%plus' as their interfaces are not distinguishable
  use opmod , operator(.add.) => operator(.adda.)
 ^^^^^
./a6.f:35:5: 'plus2' is USE-associated from module 'opmod'
  use opmod , operator(.add.) => operator(.adda.)
 ^^^^^
./a6.f:35:5: 'plus' is USE-associated from module 'opmod'
  use opmod , operator(.add.) => operator(.adda.)
      ^^^^^
```

Module procedure `plus` is not part of the accessible generic `operator(.add.)` in the scope of main. The error message seems wrong.
All ifort, gfortran and XLF all compile the code successfully.

_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to