Fortran: ICE in resolve_allocate_deallocate for invalid STAT argument
authorHarald Anlauf <anlauf@gmx.de>
Wed, 28 Jul 2021 17:11:27 +0000 (19:11 +0200)
committerHarald Anlauf <anlauf@gmx.de>
Wed, 28 Jul 2021 17:11:27 +0000 (19:11 +0200)
commit7bf582e6cfcef922a087b1b2b42aa04ea9cb2d94
treeef270e0cfb9c265bc09048967391da0b90aa224a
parent49e28c02a95a4bee981e69a80950309869580151
Fortran: ICE in resolve_allocate_deallocate for invalid STAT argument

gcc/fortran/ChangeLog:

PR fortran/101564
* expr.c (gfc_check_vardef_context): Add check for KIND and LEN
parameter inquiries.
* match.c (gfc_match): Fix comment for %v code.
(gfc_match_allocate, gfc_match_deallocate): Replace use of %v code
by %e in gfc_match to allow for function references as STAT and
ERRMSG arguments.
* resolve.c (resolve_allocate_deallocate): Avoid NULL pointer
dereferences and shortcut for bad STAT and ERRMSG argument to
(DE)ALLOCATE.  Remove bogus parts of checks for STAT and ERRMSG.

gcc/testsuite/ChangeLog:

PR fortran/101564
* gfortran.dg/allocate_stat_3.f90: New test.
* gfortran.dg/allocate_stat.f90: Adjust error messages.
* gfortran.dg/implicit_11.f90: Likewise.
* gfortran.dg/inquiry_type_ref_3.f90: Likewise.
gcc/fortran/expr.c
gcc/fortran/match.c
gcc/fortran/resolve.c
gcc/testsuite/gfortran.dg/allocate_stat.f90
gcc/testsuite/gfortran.dg/allocate_stat_3.f90 [new file with mode: 0644]
gcc/testsuite/gfortran.dg/implicit_11.f90
gcc/testsuite/gfortran.dg/inquiry_type_ref_3.f90