From 19adb97a310cd398814c5ccb75580b1658433cfc Mon Sep 17 00:00:00 2001 From: "Steven G. Kargl" Date: Sun, 16 Dec 2018 03:33:05 +0000 Subject: [PATCH] re PR fortran/87994 (ICE in match_data_constant, at fortran/decl.c:399) 2018-12-15 Steven G. Kargl PR fortran/87944 * decl.c (match_data_constant): Allow inquiry parameter as data constant in data statement. 2018-12-15 Steven G. Kargl 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 | 8 +++++++- gcc/fortran/decl.c | 8 ++++++++ gcc/testsuite/ChangeLog | 9 ++++++++- gcc/testsuite/gfortran.dg/pr87994_1.f90 | 7 +++++++ gcc/testsuite/gfortran.dg/pr87994_2.f90 | 7 +++++++ gcc/testsuite/gfortran.dg/pr87994_3.f90 | 8 ++++++++ 6 files changed, 45 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/gfortran.dg/pr87994_1.f90 create mode 100644 gcc/testsuite/gfortran.dg/pr87994_2.f90 create mode 100644 gcc/testsuite/gfortran.dg/pr87994_3.f90 diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 2fe463a1fed..0034c3b714c 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,4 +1,10 @@ -2019-12-15 Steven G. Kargl +2018-12-15 Steven G. Kargl + + PR fortran/87944 + * decl.c (match_data_constant): Allow inquiry parameter as data + constant in data statement. + +2018-12-15 Steven G. Kargl PR fortran/88138 * decl.c (variable_decl): Check that a derived isn't being assigned diff --git a/gcc/fortran/decl.c b/gcc/fortran/decl.c index 78555ce2f60..1dd3225d486 100644 --- a/gcc/fortran/decl.c +++ b/gcc/fortran/decl.c @@ -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 diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 7977fdaadde..597ba50c867 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,10 @@ +2018-12-15 Steven G. Kargl + + 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 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 +2018-12-15 Steven G. Kargl 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 index 00000000000..ed0d6b4e9d8 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr87994_1.f90 @@ -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 index 00000000000..6f20b0a2bfd --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr87994_2.f90 @@ -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 index 00000000000..c67bc0ca02c --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr87994_3.f90 @@ -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 -- 2.30.2