From a5edb32e6bf15519852b9cc321aa397ed238efef Mon Sep 17 00:00:00 2001 From: Jerry DeLisle Date: Sat, 9 Apr 2016 19:09:02 +0000 Subject: re PR fortran/68566 (ICE on using unusable array in reshape (double free or corruption)) 2016-04-09 Jerry DeLisle PR fortran/68566 * array.c (match_array_element_spec): Add check for non-integer. * simplify.c (gfc_simplify_reshape): If source shape is NULL return. PR fortran/68566 * gfortran.dg/pr36192.f90: Update test. * gfortran.dg/pr36192_1.f90: Update test. * gfortran.dg/real_dimension_1.f: Update test. * gfortran.dg/parameter_array_init_7.f90: New test. From-SVN: r234864 --- gcc/fortran/array.c | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) (limited to 'gcc/fortran/array.c') diff --git a/gcc/fortran/array.c b/gcc/fortran/array.c index 2fc9dfa..1430e80 100644 --- a/gcc/fortran/array.c +++ b/gcc/fortran/array.c @@ -421,10 +421,15 @@ match_array_element_spec (gfc_array_spec *as) if (!gfc_expr_check_typed (*upper, gfc_current_ns, false)) return AS_UNKNOWN; - if ((*upper)->expr_type == EXPR_FUNCTION && (*upper)->ts.type == BT_UNKNOWN - && (*upper)->symtree && strcmp ((*upper)->symtree->name, "null") == 0) - { - gfc_error ("Expecting a scalar INTEGER expression at %C"); + if (((*upper)->expr_type == EXPR_CONSTANT + && (*upper)->ts.type != BT_INTEGER) || + ((*upper)->expr_type == EXPR_FUNCTION + && (*upper)->ts.type == BT_UNKNOWN + && (*upper)->symtree + && strcmp ((*upper)->symtree->name, "null") == 0)) + { + gfc_error ("Expecting a scalar INTEGER expression at %C, found %s", + gfc_basic_typename ((*upper)->ts.type)); return AS_UNKNOWN; } @@ -448,10 +453,15 @@ match_array_element_spec (gfc_array_spec *as) if (!gfc_expr_check_typed (*upper, gfc_current_ns, false)) return AS_UNKNOWN; - if ((*upper)->expr_type == EXPR_FUNCTION && (*upper)->ts.type == BT_UNKNOWN - && (*upper)->symtree && strcmp ((*upper)->symtree->name, "null") == 0) + if (((*upper)->expr_type == EXPR_CONSTANT + && (*upper)->ts.type != BT_INTEGER) || + ((*upper)->expr_type == EXPR_FUNCTION + && (*upper)->ts.type == BT_UNKNOWN + && (*upper)->symtree + && strcmp ((*upper)->symtree->name, "null") == 0)) { - gfc_error ("Expecting a scalar INTEGER expression at %C"); + gfc_error ("Expecting a scalar INTEGER expression at %C, found %s", + gfc_basic_typename ((*upper)->ts.type)); return AS_UNKNOWN; } -- cgit v1.1