]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR fortran/82049 (ICE with character(*),parameter array constructor)
authorSteven G. Kargl <kargl@gcc.gnu.org>
Wed, 7 Feb 2018 21:01:00 +0000 (21:01 +0000)
committerSteven G. Kargl <kargl@gcc.gnu.org>
Wed, 7 Feb 2018 21:01:00 +0000 (21:01 +0000)
2018-02-07  Steven G. Kargl  <kargl@gcc.gnu.org>

PR fortran/82049
* match.c (gfc_match_type_spec): If the charlen is non-NULL, then
try to resolve it.  While here return early if possible.

2018-02-07  Steven G. Kargl  <kargl@gcc.gnu.org>

PR fortran/82049
* gfortran.dg/assumed_charlen_parameter.f90: New test.

From-SVN: r257461

gcc/fortran/ChangeLog
gcc/fortran/match.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/assumed_charlen_parameter.f90 [new file with mode: 0644]

index f3415473b1d81c9a2768399e660d59035643bd41..00caf4add6ed8ec8c3e488c679fe2d1063d9f421 100644 (file)
@@ -1,3 +1,9 @@
+2018-02-07  Steven G. Kargl  <kargl@gcc.gnu.org>
+
+       PR fortran/82049
+       * match.c (gfc_match_type_spec): If the charlen is non-NULL, then
+       try to resolve it.  While here return early if possible.
+
 2018-01-20  Steven G. Kargl  <kargl@gcc.gnu.org>
 
        PR fortran/83900
index eed3f61800580651e275b6ada12265e10d995a71..d3ea167355433e169b0505c8d96feaa2184a44e2 100644 (file)
@@ -1983,11 +1983,17 @@ gfc_match_type_spec (gfc_typespec *ts)
 {
   match m;
   locus old_locus;
+  char c;
 
   gfc_clear_ts (ts);
   gfc_gobble_whitespace ();
   old_locus = gfc_current_locus;
 
+  /* If c isn't in [a-z], then return immediately.  */
+  c = gfc_peek_ascii_char ();
+  if (!ISALPHA(c))
+    return MATCH_NO;
+
   if (match_derived_type_spec (ts) == MATCH_YES)
     {
       /* Enforce F03:C401.  */
@@ -2033,6 +2039,8 @@ gfc_match_type_spec (gfc_typespec *ts)
       ts->type = BT_CHARACTER;
 
       m = gfc_match_char_spec (ts);
+      if (ts->u.cl && ts->u.cl->length)
+       gfc_resolve_expr (ts->u.cl->length);
 
       if (m == MATCH_NO)
        m = MATCH_YES;
index 7b73816e9ed7b3f0adc0dd8499ab45bcc5610222..4e8db9407c9ac9686e4740899e763723506c7046 100644 (file)
@@ -1,3 +1,8 @@
+2018-02-07  Steven G. Kargl  <kargl@gcc.gnu.org>
+
+       PR fortran/82049
+       * gfortran.dg/assumed_charlen_parameter.f90: New test.
+
 2018-02-01  Renlin Li  <renlin.li@arm.com>
 
        Backport from mainline
diff --git a/gcc/testsuite/gfortran.dg/assumed_charlen_parameter.f90 b/gcc/testsuite/gfortran.dg/assumed_charlen_parameter.f90
new file mode 100644 (file)
index 0000000..2653f1b
--- /dev/null
@@ -0,0 +1,9 @@
+! { dg-do compile }
+! PR fortran/82049
+! Original code contributed by John Harper <john dot harper at vuw dot ac dot nz>
+program ice ! f2003
+  implicit none
+  character(*), parameter:: a = 'ice', b = '*'
+  character(*), parameter:: c(2) = [character(len(a)) :: a, b]
+  print "(2A4)",adjustr(c)
+end program ice