aboutsummaryrefslogtreecommitdiff
path: root/gcc/fortran/array.c
diff options
context:
space:
mode:
authorJerry DeLisle <jvdelisle@gcc.gnu.org>2016-04-09 19:09:02 +0000
committerJerry DeLisle <jvdelisle@gcc.gnu.org>2016-04-09 19:09:02 +0000
commita5edb32e6bf15519852b9cc321aa397ed238efef (patch)
tree1ced5448c700f915d81da68df88da1b2b68dd7ff /gcc/fortran/array.c
parentc532c87139a9410212ab0eff59a4980d28646bfa (diff)
downloadgcc-a5edb32e6bf15519852b9cc321aa397ed238efef.zip
gcc-a5edb32e6bf15519852b9cc321aa397ed238efef.tar.gz
gcc-a5edb32e6bf15519852b9cc321aa397ed238efef.tar.bz2
re PR fortran/68566 (ICE on using unusable array in reshape (double free or corruption))
2016-04-09 Jerry DeLisle <jvdelisle@gcc.gnu.org> 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
Diffstat (limited to 'gcc/fortran/array.c')
-rw-r--r--gcc/fortran/array.c24
1 files changed, 17 insertions, 7 deletions
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;
}