This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[Committed] PR fortran/88206 -- Fix REAL issue with array constructor
- 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: Sun, 9 Dec 2018 12:28:21 -0800
- Subject: [Committed] PR fortran/88206 -- Fix REAL issue with array constructor
- Reply-to: sgk at troutmask dot apl dot washington dot edu
The attach patch fixes an issue where REAL intrinsic can confuse
typespec rsolution in an array constructor.
2018-12-09 Steven G. Kargl <kargl@gcc.gnu.org>
PR fortran/88206
* match.c (gfc_match_type_spec): REAL can be an intrinsic function.
2018-12-09 Steven G. Kargl <kargl@gcc.gnu.org>
PR fortran/88206
* gfortran.dg/pr88206.f90: New test.
--
Steve
Index: gcc/fortran/match.c
===================================================================
--- gcc/fortran/match.c (revision 266929)
+++ gcc/fortran/match.c (working copy)
@@ -2225,6 +2225,9 @@ found:
return MATCH_NO;
}
+ if (e->expr_type != EXPR_CONSTANT)
+ goto ohno;
+
gfc_next_char (); /* Burn the ')'. */
ts->kind = (int) mpz_get_si (e->value.integer);
if (gfc_validate_kind (ts->type, ts->kind , true) == -1)
@@ -2238,6 +2241,8 @@ found:
return MATCH_YES;
}
}
+
+ohno:
/* If a type is not matched, simply return MATCH_NO. */
gfc_current_locus = old_locus;
Index: gcc/testsuite/gfortran.dg/pr88206.f90
===================================================================
--- gcc/testsuite/gfortran.dg/pr88206.f90 (nonexistent)
+++ gcc/testsuite/gfortran.dg/pr88206.f90 (working copy)
@@ -0,0 +1,8 @@
+! { dg-do compile }
+! PR fortran/88206
+program p
+ integer, parameter :: z(4) = [1,2,3,4]
+ integer :: k = 2
+ print *, [real(z(k))]
+end
+