]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR fortran/87993 (ICE in gfc_constructor_first, at fortran/constructor.c:234)
authorSteven G. Kargl <kargl@gcc.gnu.org>
Tue, 13 Aug 2019 18:27:05 +0000 (18:27 +0000)
committerSteven G. Kargl <kargl@gcc.gnu.org>
Tue, 13 Aug 2019 18:27:05 +0000 (18:27 +0000)
2019-08-13  Steven G. Kargl  <kargl@gcc.gnu.org>

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  <kargl@gcc.gnu.org>

PR fortran/87993
* gfortran.dg/pr87993.f90: New test.

From-SVN: r274390

gcc/fortran/ChangeLog
gcc/fortran/expr.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/pr87993.f90 [new file with mode: 0644]

index bcc3a0b5db20dba37ed5459cf266fd136ef68682..4b12a73a96946406b8a35ef1c350593b8f6a6395 100644 (file)
@@ -1,3 +1,9 @@
+2019-08-13  Steven G. Kargl  <kargl@gcc.gnu.org>
+
+       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  Thomas Koenig  <tkoenig@gcc.gnu.org>
 
        Backport from trunk
index 2aeea92b8fbcccd0c06aa015c68bc1e1a765af23..33a332efdffb818f7e64f0d5b4ef78f9a91b1c9c 100644 (file)
@@ -2220,6 +2220,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;
 
index 463baa672daf8a5197608e263d712ddbc2b328fb..4329b14ce933afc6b049da28200225da05301da0 100644 (file)
@@ -1,3 +1,8 @@
+2019-08-13  Steven G. Kargl  <kargl@gcc.gnu.org>
+
+       PR fortran/87993
+       * gfortran.dg/pr87993.f90: New test.
+
 2019-08-13  Thomas Koenig  <tkoenig@gcc.gnu.org>
 
        Backport from trunk
diff --git a/gcc/testsuite/gfortran.dg/pr87993.f90 b/gcc/testsuite/gfortran.dg/pr87993.f90
new file mode 100644 (file)
index 0000000..96d353d
--- /dev/null
@@ -0,0 +1,8 @@
+! { dg-do run }
+! Code contributed by Gerhard Steinmetz <gscfq at t-online dot de>
+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