From 02543f02639c5fd0bd2755699f6d19c0043801ce Mon Sep 17 00:00:00 2001 From: "Steven G. Kargl" Date: Sat, 22 Dec 2018 19:37:06 +0000 Subject: [PATCH] re PR fortran/85798 (ICE in get_array_index, at fortran/data.c:69) 2018-12-22 Steven G . Kargl PR fortran/85798 * decl.c (gfc_match_data): If a component of a derived type entity appears in data statement, check that does not have the allocatable attribute. 2018-12-22 Steven G . Kargl PR fortran/85798 * gfortran.dg/pr85798.f90: New test. From-SVN: r267356 --- gcc/fortran/ChangeLog | 7 +++++++ gcc/fortran/decl.c | 25 +++++++++++++++++++++++++ gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gfortran.dg/pr85798.f90 | 14 ++++++++++++++ 4 files changed, 51 insertions(+) create mode 100644 gcc/testsuite/gfortran.dg/pr85798.f90 diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 6f37f0954ca..276aad9c14b 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,10 @@ +2018-12-22 Steven G . Kargl + + PR fortran/85798 + * decl.c (gfc_match_data): If a component of a derived type entity + appears in data statement, check that does not have the allocatable + attribute. + 2018-12-22 Steven G. Kargl PR fortran/88169 diff --git a/gcc/fortran/decl.c b/gcc/fortran/decl.c index 83d9ac6caf2..51c19c17d1d 100644 --- a/gcc/fortran/decl.c +++ b/gcc/fortran/decl.c @@ -596,6 +596,7 @@ match gfc_match_data (void) { gfc_data *new_data; + gfc_expr *e; match m; /* Before parsing the rest of a DATA statement, check F2008:c1206. */ @@ -632,6 +633,30 @@ gfc_match_data (void) goto cleanup; } + /* Check for an entity with an allocatable component, which is not + allowed. */ + e = new_data->var->expr; + if (e) + { + bool invalid; + + invalid = false; + for (gfc_ref *ref = e->ref; ref; ref = ref->next) + if ((ref->type == REF_COMPONENT + && ref->u.c.component->attr.allocatable) + || (ref->type == REF_ARRAY + && e->symtree->n.sym->attr.pointer != 1 + && ref->u.ar.as && ref->u.ar.as->type == AS_DEFERRED)) + invalid = true; + + if (invalid) + { + gfc_error ("Allocatable component or deferred-shaped array " + "near %C in DATA statement"); + goto cleanup; + } + } + m = top_val_list (new_data); if (m != MATCH_YES) goto cleanup; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index d358d2d3a31..85495144d83 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2018-12-26 Steven G . Kargl + + PR fortran/85798 + * gfortran.dg/pr85798.f90: New test. + 2018-12-21 Steven G. Kargl PR fortran/88169 diff --git a/gcc/testsuite/gfortran.dg/pr85798.f90 b/gcc/testsuite/gfortran.dg/pr85798.f90 new file mode 100644 index 00000000000..1cc224d1fef --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr85798.f90 @@ -0,0 +1,14 @@ +! { dg-do compile } +program p + type t + integer, allocatable :: a(:) + end type + type u + real x + type(t) y + end type + type(t) :: z + type(u) :: q + data z%a(1) / 789 / ! { dg-error "Allocatable component" } + data q%y%a(1) / 789 / ! { dg-error "Allocatable component" } +end -- 2.30.2