From 8fb2cc6b24b32595ad1e50ef38a3847799574290 Mon Sep 17 00:00:00 2001 From: Thomas Koenig Date: Tue, 30 Jan 2018 22:35:34 +0000 Subject: [PATCH] re PR fortran/84134 (ICE: Floating point exception) 2017-01-30 Thomas Koenig PR fortran/84134 * array.c (gfc_ref_dimen_size): Whitespace fixes. If stride is zero, return false. 2017-01-30 Thomas Koenig PR fortran/84134 * gfortran.dg/data_implied_do_2.f90: New test. From-SVN: r257211 --- gcc/fortran/ChangeLog | 6 ++++++ gcc/fortran/array.c | 5 ++++- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gfortran.dg/data_implied_do_2.f90 | 8 ++++++++ 4 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gfortran.dg/data_implied_do_2.f90 diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 292abc15953..35894cda5d0 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,9 @@ +2017-01-30 Thomas Koenig + + PR fortran/84134 + * array.c (gfc_ref_dimen_size): Whitespace fixes. If stride is + zero, return false. + 2018-01-30 Thomas Koenig PR fortran/84133 diff --git a/gcc/fortran/array.c b/gcc/fortran/array.c index 22a5ddc59de..ee13d92fc92 100644 --- a/gcc/fortran/array.c +++ b/gcc/fortran/array.c @@ -2245,9 +2245,12 @@ gfc_ref_dimen_size (gfc_array_ref *ar, int dimen, mpz_t *result, mpz_t *end) else { stride_expr = gfc_copy_expr(ar->stride[dimen]); + if(!gfc_simplify_expr(stride_expr, 1)) gfc_internal_error("Simplification error"); - if (stride_expr->expr_type != EXPR_CONSTANT) + + if (stride_expr->expr_type != EXPR_CONSTANT + || mpz_cmp_ui (stride_expr->value.integer, 0) == 0) { mpz_clear (stride); return false; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 34a8de4a56c..e5dc2b934a4 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2017-01-30 Thomas Koenig + + PR fortran/84134 + * gfortran.dg/data_implied_do_2.f90: New test. + 2018-01-30 Janus Weil * gfortran.dg/pr68318_1.f90: Add closing bracket in dejagnu directive. diff --git a/gcc/testsuite/gfortran.dg/data_implied_do_2.f90 b/gcc/testsuite/gfortran.dg/data_implied_do_2.f90 new file mode 100644 index 00000000000..97674410d96 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/data_implied_do_2.f90 @@ -0,0 +1,8 @@ +! { dg-do compile } +! PR fortran/84134 - this used to ICE. +! Test case by Gerhard Steinmetz + +program p + integer :: i, x(3) + data (x(i+1:i+2:i),i=0,1) /1,2,3/ ! { dg-error "Nonconstant array section" } +end -- 2.30.2