Issue |
157380
|
Summary |
[Flang] No compilation error output for restrictions on generic declarations
|
Labels |
flang:frontend
|
Assignees |
|
Reporter |
ohno-fj
|
```
Version of flang : 22.0.0(eef79c8b49aa45458bbaf895603385a7819cc182)/AArch64
```
The attached program (`TBP_TBO_FT_007_2.f90`) is not correct.
The argument type determines which `procedure names (add_same and add_const)` are chosen when using `intrinsic operator (<)`.
Since `derived type (ty1)` is an extension of `derived type (ty)`, and `derived type (ty1)` can be used where `derived type (ty)` can be used, both procedures seem to work after all.
The above seems to violate the following parts.
`Fortran standard 2023: 15.4.3.4.5 Restrictions on generic declarations : C1511`
Flang should detect error during compilation for such ambiguous program.
The following are the test program, Flang, Gfortran and ifx compilation/execution result.
TBP_TBO_FT_007_2.f90:
```fortran
module mod1
type ty
integer :: ii
contains
procedure :: PRC => add_same
generic :: operator(<) => PRC
generic :: gnr => PRC
end type ty
contains
function add_same(a,b)
class(ty),INTENT(IN) :: a
integer, INTENT(IN) :: b
logical :: add_same
add_same = a%ii < b
end function add_same
end module mod1
module m2
use mod1
type, extends(ty)::ty1
integer :: jj
contains
procedure :: PRC => add_const
generic :: operator(<) => PRC
end type ty1
contains
function add_const(a,b)
integer,intent(in) :: b
class(ty1),INTENT(IN) :: a
logical add_const
add_const = a%jj < b
end function add_const
end module m2
```
```
$ flang TBP_TBO_FT_007_2.f90 -c
$
```
```
$ gfortran TBP_TBO_FT_007_2.f90 -c
TBP_TBO_FT_007_2.f90:24:32:
24 | generic :: operator(<) => PRC
| 1
Error: ‘add_const’ and ‘add_same’ for GENERIC ‘<’ at (1) are ambiguous
$
```
```
$ ifx TBP_TBO_FT_007_2.f90 -c
TBP_TBO_FT_007_2.f90(27): error #5286: Ambiguous generic interface OPERATOR(.LT.): previously declared specific procedure MOD1::ADD_SAME is not distinguishable from this declaration. [ADD_CONST]
function add_const(a,b)
-----------^
$
```
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs