From: Steven G. Kargl Date: Tue, 13 Aug 2019 18:06:08 +0000 (+0000) Subject: re PR fortran/87993 (ICE in gfc_constructor_first, at fortran/constructor.c:234) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=48668ee0d23119ee55f6c844b214342486cc8f1f;p=gcc.git re PR fortran/87993 (ICE in gfc_constructor_first, at fortran/constructor.c:234) 2019-08-13 Steven G. Kargl PR fortran/87993 * expr.c (gfc_simplify_expr): Simplifcation of an array with a kind type inquiry suffix yields a constant expression. 2019-08-13 Steven G. Kargl PR fortran/87993 * gfortran.dg/pr87993.f90: New test. From-SVN: r274388 --- diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 7131d0fb7f9..d5e44a77d5d 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,9 @@ +2019-08-13 Steven G. Kargl + + PR fortran/87993 + * expr.c (gfc_simplify_expr): Simplifcation of an array with a kind + type inquiry suffix yields a constant expression. + 2019-08-13 Janne Blomqvist PR fortran/91414 diff --git a/gcc/fortran/expr.c b/gcc/fortran/expr.c index 900242dc1ae..451609442bc 100644 --- a/gcc/fortran/expr.c +++ b/gcc/fortran/expr.c @@ -2227,6 +2227,11 @@ gfc_simplify_expr (gfc_expr *p, int type) if (!simplify_ref_chain (p->ref, type, &p)) return false; + /* If the following conditions hold, we found something like kind type + inquiry of the form a(2)%kind while simplify the ref chain. */ + if (p->expr_type == EXPR_CONSTANT && !p->ref && !p->rank && !p->shape) + return true; + if (!simplify_constructor (p->value.constructor, type)) return false; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index d577f7ed089..6f193c7ab33 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2019-08-13 Steven G. Kargl + + PR fortran/87993 + * gfortran.dg/pr87993.f90: New test. + 2019-08-13 Martin Sebor PR c/80619 diff --git a/gcc/testsuite/gfortran.dg/pr87993.f90 b/gcc/testsuite/gfortran.dg/pr87993.f90 new file mode 100644 index 00000000000..96d353d64f8 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr87993.f90 @@ -0,0 +1,8 @@ +! { dg-do run } +! Code contributed by Gerhard Steinmetz +program p + integer, parameter :: a(2) = 1 + integer, parameter :: b = a%kind + if (any(a /= 1)) stop 1 + if (b /= kind(a)) stop 2 +end