re PR fortran/87994 (ICE in match_data_constant, at fortran/decl.c:399)
authorSteven G. Kargl <kargl@gcc.gnu.org>
Sun, 16 Dec 2018 03:33:05 +0000 (03:33 +0000)
committerSteven G. Kargl <kargl@gcc.gnu.org>
Sun, 16 Dec 2018 03:33:05 +0000 (03:33 +0000)
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.

From-SVN: r267184

gcc/fortran/ChangeLog
gcc/fortran/decl.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/pr87994_1.f90 [new file with mode: 0644]
gcc/testsuite/gfortran.dg/pr87994_2.f90 [new file with mode: 0644]
gcc/testsuite/gfortran.dg/pr87994_3.f90 [new file with mode: 0644]

index 2fe463a1fed0806ac07e3f1095c70460de61f13e..0034c3b714c56c39204e1aa7a6f9d2e91f23b7dd 100644 (file)
@@ -1,4 +1,10 @@
-2019-12-15  Steven G. Kargl  <kargl@gcc.gnu.org>
+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/88138
        * decl.c (variable_decl): Check that a derived isn't being assigned
index 78555ce2f606d1fd43cf90d3e0e25949b50d75fb..1dd3225d4860811dc06e6fb7c926d6d09319af1b 100644 (file)
@@ -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 7977fdaaddedde4bc00aba54de62623a67dfb1a5..597ba50c867a22a71ee197ab2a1528efdeb04b37 100644 (file)
@@ -1,3 +1,10 @@
+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.
+
 2018-12-16  Jakub Jelinek  <jakub@redhat.com>
 
        PR c++/88482
@@ -10,7 +17,7 @@
        * g++.dg/eh/builtin11.C: New test.
        * g++.dg/parse/crash55.C: Adjust expected diagnostics.
 
-2019-12-15  Steven G. Kargl  <kargl@gcc.gnu.org>
+2018-12-15  Steven G. Kargl  <kargl@gcc.gnu.org>
 
        PR fortran/88138
        * gfortran.dg/pr88138.f90: new test.
diff --git a/gcc/testsuite/gfortran.dg/pr87994_1.f90 b/gcc/testsuite/gfortran.dg/pr87994_1.f90
new file mode 100644 (file)
index 0000000..ed0d6b4
--- /dev/null
@@ -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
diff --git a/gcc/testsuite/gfortran.dg/pr87994_2.f90 b/gcc/testsuite/gfortran.dg/pr87994_2.f90
new file mode 100644 (file)
index 0000000..6f20b0a
--- /dev/null
@@ -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
diff --git a/gcc/testsuite/gfortran.dg/pr87994_3.f90 b/gcc/testsuite/gfortran.dg/pr87994_3.f90
new file mode 100644 (file)
index 0000000..c67bc0c
--- /dev/null
@@ -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