[gcc/devel/omp/gcc-9] re PR fortran/87993 (ICE in gfc_constructor_first, at fortran/constructor.c:234)

Tobias Burnus burnus@gcc.gnu.org
Thu Mar 5 13:53:00 GMT 2020


https://gcc.gnu.org/g:6a2ca0d431615c9452cccbb13e0069763bce4c7d

commit 6a2ca0d431615c9452cccbb13e0069763bce4c7d
Author: Steven G. Kargl <kargl@gcc.gnu.org>
Date:   Tue Aug 13 18:27:05 2019 +0000

    re PR fortran/87993 (ICE in gfc_constructor_first, at fortran/constructor.c:234)
    
    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

Diff:
---
 gcc/fortran/ChangeLog                 | 6 ++++++
 gcc/fortran/expr.c                    | 5 +++++
 gcc/testsuite/ChangeLog               | 5 +++++
 gcc/testsuite/gfortran.dg/pr87993.f90 | 8 ++++++++
 4 files changed, 24 insertions(+)

diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog
index bcc3a0b..4b12a73 100644
--- a/gcc/fortran/ChangeLog
+++ b/gcc/fortran/ChangeLog
@@ -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
diff --git a/gcc/fortran/expr.c b/gcc/fortran/expr.c
index 2aeea92..33a332e 100644
--- a/gcc/fortran/expr.c
+++ b/gcc/fortran/expr.c
@@ -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;
 
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 463baa6..4329b14 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -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
index 0000000..96d353d
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/pr87993.f90
@@ -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



More information about the Gcc-cvs mailing list