Hi all,
The front-end is not consistently checking for errors with character parameters
as internal units. The reason is we never actually checked for this before. In
some cases an error message is triggered from other unrelated causes or
sometimes no error is given at all.
This is fixed by the attached patch that adds the check in gfc_resolve_dt. I had
to place the check before the unit expression is resolved because somewhere in
gfc_resolve_expr the attribute information does not trigger for at least one
test case (lost?).
All cases I found are included in the test case. Regression tested on
x86_64-pc-linux-gnu.
OK for trunk?
Regards,
Jerry
2019-06-22 Jerry DeLisle <jvdeli...@gcc.gnu.org>
PR fortran/89782
* io.c (gfc_resolve_dt): Check that internal units are not
character PARAMETER.
* gfortran.dg/io_constraints.f90: New test.
! { dg-do compile }
program pr89782
character(len=*),parameter :: VALUES(*)=[character(len=10) :: 'NaN','NAN','nan','Inf','INF','inf','Infinity']
character(len=*),parameter :: VALUE='NaN'
real(4) :: var
do i=1,size(VALUES)
read(VALUES(i),*) float ! { dg-error "character PARAMETER" }
write(VALUES(i),*)float ! { dg-error "character PARAMETER" }
enddo
read(var,*)float ! { dg-error "INTEGER expression or a CHARACTER" }
read(VALUE,*)float ! { dg-error "character PARAMETER" }
write(VALUE,*)float ! { dg-error "character PARAMETER" }
end program pr89782