aboutsummaryrefslogtreecommitdiff
path: root/gcc/fortran/expr.c
diff options
context:
space:
mode:
authorTobias Burnus <burnus@net-b.de>2018-10-12 20:18:13 +0200
committerTobias Burnus <burnus@gcc.gnu.org>2018-10-12 20:18:13 +0200
commit47b92d22d3aea04ce6a936c768953dd0406f41c2 (patch)
tree3aa254da8f50163132eac6447ce9497870ab06cb /gcc/fortran/expr.c
parentb4439561c4019cf3bc4c59cc6260d7464917f1e5 (diff)
downloadgcc-47b92d22d3aea04ce6a936c768953dd0406f41c2.zip
gcc-47b92d22d3aea04ce6a936c768953dd0406f41c2.tar.gz
gcc-47b92d22d3aea04ce6a936c768953dd0406f41c2.tar.bz2
Fix off-by-one issue with inline matmul
PR fortran/87597 * expr.c (gfc_simplify_expr): Avoid simplifying the 'array' argument to lbound/ubound/lcobound/ ucobound. PR fortran/87597 * gfortran.dg/inline_matmul_24.f90: New. From-SVN: r265126
Diffstat (limited to 'gcc/fortran/expr.c')
-rw-r--r--gcc/fortran/expr.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/gcc/fortran/expr.c b/gcc/fortran/expr.c
index 1cfda5f..ca6f95d 100644
--- a/gcc/fortran/expr.c
+++ b/gcc/fortran/expr.c
@@ -1937,7 +1937,20 @@ gfc_simplify_expr (gfc_expr *p, int type)
break;
case EXPR_FUNCTION:
- for (ap = p->value.function.actual; ap; ap = ap->next)
+ // For array-bound functions, we don't need to optimize
+ // the 'array' argument. In particular, if the argument
+ // is a PARAMETER, simplifying might convert an EXPR_VARIABLE
+ // into an EXPR_ARRAY; the latter has lbound = 1, the former
+ // can have any lbound.
+ ap = p->value.function.actual;
+ if (p->value.function.isym &&
+ (p->value.function.isym->id == GFC_ISYM_LBOUND
+ || p->value.function.isym->id == GFC_ISYM_UBOUND
+ || p->value.function.isym->id == GFC_ISYM_LCOBOUND
+ || p->value.function.isym->id == GFC_ISYM_UCOBOUND))
+ ap = ap->next;
+
+ for ( ; ap; ap = ap->next)
if (!gfc_simplify_expr (ap->expr, type))
return false;