aboutsummaryrefslogtreecommitdiff
path: root/gcc/fortran/expr.c
diff options
context:
space:
mode:
authorHarald Anlauf <anlauf@gmx.de>2021-07-28 19:11:27 +0200
committerHarald Anlauf <anlauf@gmx.de>2021-07-28 19:11:27 +0200
commit7bf582e6cfcef922a087b1b2b42aa04ea9cb2d94 (patch)
treeef270e0cfb9c265bc09048967391da0b90aa224a /gcc/fortran/expr.c
parent49e28c02a95a4bee981e69a80950309869580151 (diff)
downloadgcc-7bf582e6cfcef922a087b1b2b42aa04ea9cb2d94.zip
gcc-7bf582e6cfcef922a087b1b2b42aa04ea9cb2d94.tar.gz
gcc-7bf582e6cfcef922a087b1b2b42aa04ea9cb2d94.tar.bz2
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.
Diffstat (limited to 'gcc/fortran/expr.c')
-rw-r--r--gcc/fortran/expr.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/gcc/fortran/expr.c b/gcc/fortran/expr.c
index b11ae7c..35563a7 100644
--- a/gcc/fortran/expr.c
+++ b/gcc/fortran/expr.c
@@ -6199,6 +6199,16 @@ gfc_check_vardef_context (gfc_expr* e, bool pointer, bool alloc_obj,
if (!pointer)
check_intentin = false;
}
+ if (ref->type == REF_INQUIRY
+ && (ref->u.i == INQUIRY_KIND || ref->u.i == INQUIRY_LEN))
+ {
+ if (context)
+ gfc_error ("%qs parameter inquiry for %qs in "
+ "variable definition context (%s) at %L",
+ ref->u.i == INQUIRY_KIND ? "KIND" : "LEN",
+ sym->name, context, &e->where);
+ return false;
+ }
}
if (check_intentin