This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[Committed] PR fortran/87994 -- Inquiry parameter as data constant
- From: Steve Kargl <sgk at troutmask dot apl dot washington dot edu>
- To: fortran at gcc dot gnu dot org, gcc-patches at gcc dot gnu dot org
- Date: Sat, 15 Dec 2018 19:35:38 -0800
- Subject: [Committed] PR fortran/87994 -- Inquiry parameter as data constant
- Reply-to: sgk at troutmask dot apl dot washington dot edu
I've committed the attached after testing on i586-*-freebsd
and x86_64-*-freebsd. It removes an ICE by allowing the
inquiry parametes of len and kind in data statements as
data constants.
2018-12-15 Steven G. Kargl <kargl@gcc.gnu.org>
PR fortran/87944
* decl.c (match_data_constant): Allow inquiry parameter as data
constant in data statement.
2018-12-15 Steven G. Kargl <kargl@gcc.gnu.org>
PR fortran/87944
* gfortran.dg/pr87994_1.f90: New test.
* gfortran.dg/pr87994_2.f90: Ditto.
* gfortran.dg/pr87994_3.f90: Ditto.
--
Steve
Index: gcc/fortran/decl.c
===================================================================
--- gcc/fortran/decl.c (revision 267180)
+++ gcc/fortran/decl.c (working copy)
@@ -399,6 +399,14 @@ match_data_constant (gfc_expr **result)
}
else if (m == MATCH_YES)
{
+ /* If a parameter inquiry ends up here, symtree is NULL but **result
+ contains the right constant expression. Check here. */
+ if ((*result)->symtree == NULL
+ && (*result)->expr_type == EXPR_CONSTANT
+ && ((*result)->ts.type == BT_INTEGER
+ || (*result)->ts.type == BT_REAL))
+ return m;
+
/* F2018:R845 data-stmt-constant is initial-data-target.
A data-stmt-constant shall be ... initial-data-target if and
only if the corresponding data-stmt-object has the POINTER
Index: gcc/testsuite/gfortran.dg/pr87994_1.f90
===================================================================
--- gcc/testsuite/gfortran.dg/pr87994_1.f90 (nonexistent)
+++ gcc/testsuite/gfortran.dg/pr87994_1.f90 (working copy)
@@ -0,0 +1,7 @@
+! { dg-do run }
+! PR fortran/87994
+program p
+ real :: a, b
+ data b /a%kind/
+ if (b /= kind(a)) stop 1
+end
Index: gcc/testsuite/gfortran.dg/pr87994_2.f90
===================================================================
--- gcc/testsuite/gfortran.dg/pr87994_2.f90 (nonexistent)
+++ gcc/testsuite/gfortran.dg/pr87994_2.f90 (working copy)
@@ -0,0 +1,7 @@
+! { dg-do run }
+! PR fortran/87994
+program p
+ real, parameter :: a = 1.0
+ data b /a%kind/
+ if (b /= kind(a)) stop 1
+end
Index: gcc/testsuite/gfortran.dg/pr87994_3.f90
===================================================================
--- gcc/testsuite/gfortran.dg/pr87994_3.f90 (nonexistent)
+++ gcc/testsuite/gfortran.dg/pr87994_3.f90 (working copy)
@@ -0,0 +1,8 @@
+! { dg-do run }
+! PR fortran/87994
+program p
+ integer, parameter :: a = 1
+ integer :: b
+ data b /a%kind/
+ if (b /= kind(a)) stop = 1
+end