<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/122764>122764</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[Flang] Incorrect diagnostic on renaming generic operator
</td>
</tr>
<tr>
<th>Labels</th>
<td>
flang:frontend
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
DanielCChen
</td>
</tr>
</table>
<pre>
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.
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJzEVV-PozYQ_zTOy2iRY0IIDzxw2U1VqdVV16vU14kZiCtjI9vsbb59ZUOSzW63VdVKFxFh7Jnf_GY8f9B71RuimhWfWPG4wimcrKsf0SjS-_2JzOpo23O9t8arlhyEE0FntbbflOlB2pZY3jDesC1fHt4Mtp00gR0H28Yj3gCE80gw2NYR6rQBEJcQtfMGXhY5aU1AZfwiAjA6K6mdHF0kRz39w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