aboutsummaryrefslogtreecommitdiff
path: root/gcc/fortran
diff options
context:
space:
mode:
authorMark Eggleston <markeggleston@gcc.gnu.org>2020-04-01 09:52:41 +0100
committerMark Eggleston <markeggleston@gcc.gnu.org>2020-05-28 13:24:04 +0100
commit3ea6977d0f1813d982743a09660eec1760e981ec (patch)
tree6df9a90381813ee0a99c73b956b1375c18f1a4ca /gcc/fortran
parent59a3d73d50a1fd3c392e421ba4c07966ce045043 (diff)
downloadgcc-3ea6977d0f1813d982743a09660eec1760e981ec.zip
gcc-3ea6977d0f1813d982743a09660eec1760e981ec.tar.gz
gcc-3ea6977d0f1813d982743a09660eec1760e981ec.tar.bz2
Fortran : "type is( real(kind(1.)) )" spurious syntax error PR94397
Based on a patch in the comments of the PR. That patch fixed this problem but caused the test cases for PR93484 to fail. It has been changed to reduce initialisation expressions if the expression is not EXPR_VARIABLE and not EXPR_CONSTANT. 2020-05-28 Steven G. Kargl <kargl@gcc.gnu.org> Mark Eggleston <markeggleston@gcc.gnu.org> gcc/fortran/ PR fortran/94397 * match.c (gfc_match_type_spec): New variable ok initialised to true. Set ok with the return value of gfc_reduce_init_expr called only if the expression is not EXPR_CONSTANT and is not EXPR_VARIABLE. Add !ok to the check for type not being integer or the rank being greater than zero. 2020-05-28 Mark Eggleston <markeggleston@gcc.gnu.org> gcc/testsuite/ PR fortran/94397 * gfortran.dg/pr94397.F90: New test.
Diffstat (limited to 'gcc/fortran')
-rw-r--r--gcc/fortran/match.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/gcc/fortran/match.c b/gcc/fortran/match.c
index 8ae34a9..82d2b50 100644
--- a/gcc/fortran/match.c
+++ b/gcc/fortran/match.c
@@ -2265,7 +2265,10 @@ found:
a scalar integer initialization-expr and valid kind parameter. */
if (c == ')')
{
- if (e->ts.type != BT_INTEGER || e->rank > 0)
+ bool ok = true;
+ if (e->expr_type != EXPR_CONSTANT && e->expr_type != EXPR_VARIABLE)
+ ok = gfc_reduce_init_expr (e);
+ if (!ok || e->ts.type != BT_INTEGER || e->rank > 0)
{
gfc_free_expr (e);
return MATCH_NO;