Issue |
98982
|
Summary |
[Flang] Array with allocatable attribute is dynamically created without allocate statement
|
Labels |
flang:frontend
|
Assignees |
|
Reporter |
ohno-fj
|
```
Version of flang-new : 19.0.0(73447a3302541c343525570222b318e7f94f9402)/AArch64
```
Array with `allocatable` attribute is dynamically created without `allocate statement`.
This is an error checking program. The result value is true when the array is checked in the program with `allocated intrinsic function`.
Gfortran outputs a warning message (with `-Wall` option) and does not seem to dynamically create the array. (The result value of `allocated` intrinsic function is true.)
ifort appears to output a warning message and create the array dynamically. (The result value of `allocated` intrinsic function is false.)
It seems that Flang-new creates the array dynamically, but do we need to output a warning message? (The result value of `allocated` intrinsic function is true.)
The following are the test program, Flang-new, Gfortran and ifort compilation/execution result.
fe1nalc34_2.f95:
```fortran
module typ
type xxx
integer,allocatable :: ai(:)
end type xxx
end module typ
module mod
use typ
contains
subroutine modsub(aa,item)
type(xxx),intent(in) :: aa
integer,intent(in) :: item
integer :: error = 0
select case(item)
case(1)
if (allocated(aa%ai )) error = error+1
print *," +++ fe1nalc34-S-1 : NG +++ ",error
end select
end subroutine modsub
end module mod
program fe1nalc34
use typ
use mod
integer,allocatable :: ai(:)
type(xxx) :: aa
integer :: res
interface
function funi(item) result(ai)
integer,allocatable :: ai(:)
integer,intent(in) :: item
endfunction funi
end interface
call modsub(xxx(funi(2)),1)
end program fe1nalc34
function funi(item) result(ai)
integer,allocatable :: ai(:)
integer,intent(in) :: item
select case(item)
case(1)
return
end select
end function funi
```
```
$ flang-new fe1nalc34_2.f95; ./a.out
+++ fe1nalc34-S-1 : NG +++ 1
$
```
```
$ gfortran fe1nalc34_2.f95; ./a.out
fe1nalc34_2.f95:37:30:
37 | function funi(item) result(ai)
| 1
Warning: Unused variable ‘ai’ declared at (1) [-Wunused-variable]
fe1nalc34_2.f95:37:30:
37 | function funi(item) result(ai)
| 1
Warning: Return value ‘ai’ of function ‘funi’ declared at (1) not set [-Wreturn-type]
fe1nalc34_2.f95:26:17:
26 | type(xxx) :: aa
| 1
Warning: Unused variable ‘aa’ declared at (1) [-Wunused-variable]
fe1nalc34_2.f95:25:30:
25 | integer,allocatable :: ai(:)
| 1
Warning: Unused variable ‘ai’ declared at (1) [-Wunused-variable]
fe1nalc34_2.f95:27:16:
27 | integer :: res
| 1
Warning: Unused variable ‘res’ declared at (1) [-Wunused-variable]
+++ fe1nalc34-S-1 : NG +++ 0
$
```
```
$ ifort -diag-disable=10448 fe1nalc34_2.f90
fe1nalc34_22.f90(38): warning #6178: The return value of this FUNCTION has not been defined. [AI]
function funi(item) result(ai)
---------------------------^
+++ fe1nalc34-S-1 : NG +++ 1
$
```
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs