* [Committed] PR fortran/88206 -- Fix REAL issue with array constructor
@ 2018-12-09 20:28 Steve Kargl
0 siblings, 0 replies; only message in thread
From: Steve Kargl @ 2018-12-09 20:28 UTC (permalink / raw)
To: fortran, gcc-patches
[-- Attachment #1: Type: text/plain, Size: 365 bytes --]
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
[-- Attachment #2: pr88206.diff --]
[-- Type: text/x-diff, Size: 1011 bytes --]
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
+
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2018-12-09 20:28 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-12-09 20:28 [Committed] PR fortran/88206 -- Fix REAL issue with array constructor 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).