From 650f7d09d22fc876bdceb93a47d2abf068c676db Mon Sep 17 00:00:00 2001 From: Thomas Koenig Date: Sun, 24 Sep 2017 08:39:00 +0000 Subject: [PATCH] re PR fortran/80118 (ICE with zero size parameter array) 2017-09-24 Thomas Koenig Steven G. Kargl PR fortran/80118 * expr.c (gfc_get_full_arrayspec_from_expr): If there is no symtree, set array spec to NULL. 2017-09-24 Thomas Koenig Steven G. Kargl PR fortran/80118 * gfortran.dg/zero_sized_7.f90: New test. Co-Authored-By: Steven G. Kargl From-SVN: r253123 --- gcc/fortran/ChangeLog | 7 +++++++ gcc/fortran/expr.c | 6 +++++- gcc/testsuite/ChangeLog | 6 ++++++ gcc/testsuite/gfortran.dg/zero_sized_7.f90 | 18 ++++++++++++++++++ 4 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gfortran.dg/zero_sized_7.f90 diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index c3c4f188737..29504c85b18 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,10 @@ +2017-09-24 Thomas Koenig + Steven G. Kargl + + PR fortran/80118 + * expr.c (gfc_get_full_arrayspec_from_expr): If there is + no symtree, set array spec to NULL. + 2017-09-23 Janus Weil PR fortran/82143 diff --git a/gcc/fortran/expr.c b/gcc/fortran/expr.c index 87ea09f03d6..bfbb19ee577 100644 --- a/gcc/fortran/expr.c +++ b/gcc/fortran/expr.c @@ -4568,7 +4568,11 @@ gfc_get_full_arrayspec_from_expr (gfc_expr *expr) if (expr->expr_type == EXPR_VARIABLE || expr->expr_type == EXPR_CONSTANT) { - as = expr->symtree->n.sym->as; + if (expr->symtree) + as = expr->symtree->n.sym->as; + else + as = NULL; + for (ref = expr->ref; ref; ref = ref->next) { switch (ref->type) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index c1a38f8add3..bc23562b1b9 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2017-09-24 Thomas Koenig + Steven G. Kargl + + PR fortran/80118 + * gfortran.dg/zero_sized_7.f90: New test. + 2017-09-23 Janus Weil PR fortran/82143 diff --git a/gcc/testsuite/gfortran.dg/zero_sized_7.f90 b/gcc/testsuite/gfortran.dg/zero_sized_7.f90 new file mode 100644 index 00000000000..7908532eaea --- /dev/null +++ b/gcc/testsuite/gfortran.dg/zero_sized_7.f90 @@ -0,0 +1,18 @@ +! { dg-do compile } +! PR 80118 - this used to ICE +! Original test case by Marco Restelli +module m +implicit none + + integer, parameter :: not_empty(1) = 0 + integer, parameter :: empty1(0) = (/integer :: /) + integer, parameter :: empty2(0) = 0 + +contains + + subroutine sub(v) + integer, allocatable, intent(out) :: v(:) + v = 2*empty2 ! internal compiler error + end subroutine sub + +end module m -- 2.30.2