| Issue |
170780
|
| Summary |
[Flang] Unnecessary portability warning when passing NULL() to ALLOCATABLE INTENT(IN) dummy argument
|
| Labels |
flang
|
| Assignees |
|
| Reporter |
nakazawa-fj
|
```
Version of flang : 22.0.0git(7761a89e1230d8ccbb8e6ee15dc14ea74792a53c)/AArch64
```
In the attached program (`sample.f90`), a dummy argument has the `ALLOCATABLE` attribute and `INTENT(IN)`,
and passing the intrinsic function `NULL()` as the actual argument triggers a message prefixed with `portability:`.
However, the program conforms to the Fortran 2023 standard, and this message appears redundant.
The following are the test program, Flang, Gfortran and ifx compilation/execution results.
sample.f90
```fortran
integer,allocatable::x
call sub(NULL(x))
call sub(NULL())
print*,"pass"
contains
subroutine sub(dmy)
integer,allocatable,intent(in):: dmy
if (allocated(dmy)) print *,101
end subroutine sub
end program
```
```
$ flang sample.f90
./sample.f90:3:12: portability: Allocatable dummy argument 'dmy=' is associated with NULL() [-Wnull-actual-for-allocatable]
call sub(NULL())
^^^^^^
```
```
$ gfortran sample.f90
sample.f90:2:19:
2 | call sub(NULL(x))
| 1
Error: Unexpected NULL() intrinsic at (1) to dummy ‘dmy’
sample.f90:3:18:
3 | call sub(NULL())
| 1
Error: Unexpected NULL() intrinsic at (1) to dummy ‘dmy’
```
```
$ ifx sample.f90
$ ./a.out
pass
```
According to the Fortran standard:
Fortran 2023
8.5.3: ALLOCATABLE attribute
15.5.2.7: Allocatable dummy variables
16.9.155: NULL ([MOLD])
Table 16.5: Characteristics of the result of NULL()
A dummy argument with `ALLOCATABLE` requires the actual argument to be allocatable.
`NULL()` returns an unallocated allocatable entity when used as an actual argument.
When MOLD is omitted, the characteristics of the result follow the corresponding dummy argument.
Therefore, the sample program complies with the standard. The portability warning is unnecessary and likely indicates an issue in flang's handling of `NULL()` in this context.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs