public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [Committed] PR fortran/87994 -- Inquiry parameter as data constant
@ 2018-12-16  3:35 Steve Kargl
  0 siblings, 0 replies; only message in thread
From: Steve Kargl @ 2018-12-16  3:35 UTC (permalink / raw)
  To: fortran, gcc-patches

[-- Attachment #1: Type: text/plain, Size: 546 bytes --]

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

[-- Attachment #2: pr87994.diff --]
[-- Type: text/x-diff, Size: 1933 bytes --]

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

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2018-12-16  3:35 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-12-16  3:35 [Committed] PR fortran/87994 -- Inquiry parameter as data constant Steve Kargl

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).