Issue 128607
Summary [Flang] Compilation error for the same type of two data elements declared with reference to the same derived type definition
Labels flang:frontend
Assignees
Reporter ohno-fj
    ```
Version of flang : 21.0.0(f75126eeabba13ce2aab53c2e4296fca12b9da0d)/AArch64
```

The attached program has the same `derived type (ty)` definitions in the `specification-part` and `module-subprogram-part` in `module`, and data elements declared with reference to these `derived types`.  
The data elements are of the same type, as described in `Fortran standard 2023: 7.5.2.4 Determination of derived types`.  
So this program seems to be correct, but it results in a compilation error.  

The following are the test program, Flang, Gfortran and ifx compilation/execution result.

sngg430l_32.f90:
```fortran
module m
  type ty
 integer::x
  end type ty
  interface assignment(=)
     procedure operator_overload
  end interface assignment(=)
contains
  subroutine operator_overload(t1,p1)
    type ty
       integer::x
    end type ty
 type(ty),intent(inout)::t1
    integer,intent(in)::p1
    t1%x=p1
 write(6,*) "t1%x = ", t1%x, " p1 = ", p1
  end subroutine operator_overload
end module m

program main
  use m
  integer::x
 type(ty)::obj
  x=10
  obj= x
  write(6,*) "obj%x = ", obj%x
  if(obj%x .ne. 10)print*,"100"
  print*,"pass"
end program main
```

```
$ flang sngg430l_32.f90
error: Semantic errors in sngg430l_32.f90
./sngg430l_32.f90:25:3: error: No intrinsic or user-defined ASSIGNMENT(=) matches operand types TYPE(ty) and INTEGER(4)
    obj= x
 ^^^^^^
$ 
```

```
$ gfortran sngg430l_32.f90
sngg430l_32.f90:25:7:

 25 |   obj= x
      |       1
Error: Cannot convert INTEGER(4) to TYPE(ty) at (1)
$ 
```

```
$ ifx sngg430l.f90_32; ./a.out
 t1%x = 10  p1 =           10
 obj%x =           10
 pass
$ 
```

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

Reply via email to