https://gcc.gnu.org/bugzilla/show_bug.cgi?id=123106
Bug ID: 123106
Summary: Static analyzer support for recusive Fortran print
statments
Product: gcc
Version: 16.0
Status: UNCONFIRMED
Keywords: diagnostic
Severity: enhancement
Priority: P3
Component: analyzer
Assignee: dmalcolm at gcc dot gnu.org
Reporter: pinskia at gcc dot gnu.org
Target Milestone: ---
Take:
```
print *, foo_io()
contains
function foo_io()
integer :: foo_io(2)
print * , "foo"
foo_io = [42, 42]
end function
end
```
This currently hangs at runtime because it is violating the Fortran restriction
on output statements. It would be interesting to have analyzer support to
detect this case.
The IR:
```
MAIN() {
...
dt_parm.6.common.unit = 6;
_gfortran_st_write (&dt_parm.6);
...
foo_io (&atmp.7); [static-chain: &FRAME.13];
...
_gfortran_st_write_done (&dt_parm.6);
}
foo_io () {
...
dt_parm.0.common.unit = 6;
_gfortran_st_write (&dt_parm.0);
}
```
Basically with the 2 units here matching up (6) with the start of the write
should cause a warning for invalid the recusive IO.