diff options
author | Thomas Koenig <tkoenig@gcc.gnu.org> | 2018-03-06 23:50:01 +0000 |
---|---|---|
committer | Thomas Koenig <tkoenig@gcc.gnu.org> | 2018-03-06 23:50:01 +0000 |
commit | 5867bb9a60ed0ff73627180a4f2193b0087711bf (patch) | |
tree | cb4db9278ec8f7d85bef6aff9e215f7833d4b62b /gcc/fortran/expr.c | |
parent | 447346e465c50ad6d840c2c29c9a07417e8d219c (diff) | |
download | gcc-5867bb9a60ed0ff73627180a4f2193b0087711bf.zip gcc-5867bb9a60ed0ff73627180a4f2193b0087711bf.tar.gz gcc-5867bb9a60ed0ff73627180a4f2193b0087711bf.tar.bz2 |
re PR fortran/84697 (minloc/maxloc not simplified with zero size)
2017-03-06 Thomas Koenig <tkoenig@gcc.gnu.org>
PR fortran/84697
PR fortran/66128
* expr.c (simplify_parameter_variable): If p is a size zero array
and not an ARRAY_EXPR insert an empty array constructor and
return.
* gfortran.h: Add prototype for gfc_is_size_zero_array.
* simplify.c (is_size_zero_array): Make non-static and rename into
(gfc_is_size_zero_array): Check for parameter arrays of zero
size by comparing shape and absence of constructor.
(gfc_simplify_all): Use gfc_is_size_zero_array instead of
is_size_zero_array.
(gfc_simplify_count): Likewise.
(gfc_simplify_iall): Likewise.
(gfc_simplify_iany): Likewise.
(gfc_simplify_iparity): Likewise.
(gfc_simplify_minval): Likewise.
(gfc_simplify_maxval): Likewise.
(gfc_simplify_product): Likewise.
(gfc_simplify_sum): Likewise.
2017-03-06 Thomas Koenig <tkoenig@gcc.gnu.org>
PR fortran/84697
PR fortran/66128
* gfortran.dg/minmaxloc_zerosize_1.f90: New test.
From-SVN: r258305
Diffstat (limited to 'gcc/fortran/expr.c')
-rw-r--r-- | gcc/fortran/expr.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/gcc/fortran/expr.c b/gcc/fortran/expr.c index 40f20c9..bbaabb6 100644 --- a/gcc/fortran/expr.c +++ b/gcc/fortran/expr.c @@ -1857,6 +1857,22 @@ simplify_parameter_variable (gfc_expr *p, int type) gfc_expr *e; bool t; + if (gfc_is_size_zero_array (p)) + { + if (p->expr_type == EXPR_ARRAY) + return true; + + e = gfc_get_expr (); + e->expr_type = EXPR_ARRAY; + e->ts = p->ts; + e->rank = p->rank; + e->value.constructor = NULL; + e->shape = gfc_copy_shape (p->shape, p->rank); + e->where = p->where; + gfc_replace_expr (p, e); + return true; + } + e = gfc_copy_expr (p->symtree->n.sym->value); if (e == NULL) return false; |