diff mbox series

[Committed] PR fortran/88206 -- Fix REAL issue with array constructor

Message ID 20181209202821.GA89818@troutmask.apl.washington.edu
State New
Headers show
Series [Committed] PR fortran/88206 -- Fix REAL issue with array constructor | expand

Commit Message

Steve Kargl Dec. 9, 2018, 8:28 p.m. UTC
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.
diff mbox series

Patch

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
+