From b04bebdb1dee362255b99e91cc48798291448dc6 Mon Sep 17 00:00:00 2001 From: Thomas Koenig Date: Wed, 18 Oct 2017 20:32:34 +0000 Subject: [PATCH] re PR fortran/79795 (Fortran ICE in resolve_symbol starting with r163221) 2017-10-18 Thomas Koenig PR fortran/79795 * resolve.c (resovle_symbol): Change gcc_assert to sensible error message. 2017-10-18 Thomas Koenig PR fortran/79795 * gfortran.dg/assumed_size_2.f90: New test. From-SVN: r253868 --- gcc/fortran/ChangeLog | 6 ++++++ gcc/fortran/resolve.c | 18 +++++++++++++++++- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gfortran.dg/assumed_size_2.f90 | 4 ++++ 4 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gfortran.dg/assumed_size_2.f90 diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index ab266509879..8b9f90eeb0f 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,9 @@ +2017-10-18 Thomas Koenig + + PR fortran/79795 + * resolve.c (resovle_symbol): Change gcc_assert to + sensible error message. + 2017-10-18 Paul Thomas PR fortran/82550 diff --git a/gcc/fortran/resolve.c b/gcc/fortran/resolve.c index 5e4988e6945..178854bb0ae 100644 --- a/gcc/fortran/resolve.c +++ b/gcc/fortran/resolve.c @@ -14403,7 +14403,23 @@ resolve_symbol (gfc_symbol *sym) if (as) { - gcc_assert (as->type != AS_IMPLIED_SHAPE); + /* If AS_IMPLIED_SHAPE makes it to here, it must be a bad + specification expression. */ + if (as->type == AS_IMPLIED_SHAPE) + { + int i; + for (i=0; irank; i++) + { + if (as->lower[i] != NULL && as->upper[i] == NULL) + { + gfc_error ("Bad specification for assumed size array at %L", + &as->lower[i]->where); + return; + } + } + gcc_unreachable(); + } + if (((as->type == AS_ASSUMED_SIZE && !as->cp_was_assumed) || as->type == AS_ASSUMED_SHAPE) && !sym->attr.dummy && !sym->attr.select_type_temporary) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index c44b420782f..a792c359d00 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2017-10-18 Thomas Koenig + + PR fortran/79795 + * gfortran.dg/assumed_size_2.f90: New test. + 2017-10-18 Uros Bizjak Jakub Jelinek diff --git a/gcc/testsuite/gfortran.dg/assumed_size_2.f90 b/gcc/testsuite/gfortran.dg/assumed_size_2.f90 new file mode 100644 index 00000000000..e9a1185b527 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/assumed_size_2.f90 @@ -0,0 +1,4 @@ +! { dg-do compile } +subroutine foo(a) + dimension a(*,*) ! { dg-error "Bad specification for assumed size array" } +end -- 2.30.2