From: Thomas Koenig Date: Sun, 13 Oct 2019 13:42:30 +0000 (+0000) Subject: re PR fortran/92017 (ICE in gfc_expr_attr, at fortran/primary.c:2674) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=19400cb96ce8fde3268d0b476d4d3c1efe3d3728;p=gcc.git re PR fortran/92017 (ICE in gfc_expr_attr, at fortran/primary.c:2674) 2019-10-13 Thomas Koenig PR fortran/92017 * expr.c (simplify_parameter_variable): Set the character length of the result expression from the original expression if necessary. 2019-10-13 Thomas Koenig PR fortran/92017 * gfortran.dg/minmaxloc_14.f90: New test. From-SVN: r276938 --- diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 82164d713ae..52f30dd58f5 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,10 @@ +2019-10-13 Thomas Koenig + + PR fortran/92017 + * expr.c (simplify_parameter_variable): Set the character length + of the result expression from the original expression if + necessary. + 2019-10-11 Steven G. Kargl PR fortran/91649 diff --git a/gcc/fortran/expr.c b/gcc/fortran/expr.c index 9f638fe4dc3..c508890d68d 100644 --- a/gcc/fortran/expr.c +++ b/gcc/fortran/expr.c @@ -2066,6 +2066,9 @@ simplify_parameter_variable (gfc_expr *p, int type) e->rank = p->rank; + if (e->ts.type == BT_CHARACTER && e->ts.u.cl == NULL) + e->ts.u.cl = gfc_new_charlen (gfc_current_ns, p->ts.u.cl); + /* Do not copy subobject refs for constant. */ if (e->expr_type != EXPR_CONSTANT && p->ref != NULL) e->ref = gfc_copy_ref (p->ref); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 3117a07942c..b914cb8fd42 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2019-10-13 Thomas Koenig + + PR fortran/92017 + * gfortran.dg/minmaxloc_14.f90: New test. + 2019-10-13 Rainer Orth * lib/target-supports.exp (add_options_for_c99_runtime): Remove. diff --git a/gcc/testsuite/gfortran.dg/minmaxloc_14.f90 b/gcc/testsuite/gfortran.dg/minmaxloc_14.f90 new file mode 100644 index 00000000000..d24d03f0af4 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/minmaxloc_14.f90 @@ -0,0 +1,12 @@ +! { dg-do compile } +! PR 92017 - this used to cause an ICE due do a missing charlen. +! Original test case by Gerhard Steinmetz. + +program p + character(3), parameter :: a(4) = 'abc' + integer, parameter :: b(1) = minloc(a) + integer, parameter :: c = minloc(a, dim=1) + integer, parameter :: bb(1) = maxloc(a) + integer, parameter :: c2 = maxloc(a,dim=1) +end program p +