re PR fortran/82049 (ICE with character(*),parameter array constructor)
authorSteven G. Kargl <kargl@gcc.gnu.org>
Wed, 7 Feb 2018 20:43:33 +0000 (20:43 +0000)
committerSteven G. Kargl <kargl@gcc.gnu.org>
Wed, 7 Feb 2018 20:43:33 +0000 (20:43 +0000)
2018-02-06  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-06  Steven G. Kargl  <kargl@gcc.gnu.org>

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

From-SVN: r257459

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

index 4095c011ae05f36d28db67df509f8167cfd951f0..4b2343c9ed7bd4414c0cdc2adc923e83cce1284b 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-02-04  Paul Thomas  <pault@gcc.gnu.org>
 
        PR fortran/84115
index cf44fabb2397340afa658933b8fc544ab23341f9..7bce34b56a0196c232f6ac9d29e63cb66b16775b 100644 (file)
@@ -2054,11 +2054,17 @@ gfc_match_type_spec (gfc_typespec *ts)
 {
   match m;
   locus old_locus;
-  char name[GFC_MAX_SYMBOL_LEN + 1];
+  char c, name[GFC_MAX_SYMBOL_LEN + 1];
 
   gfc_clear_ts (ts);
   gfc_gobble_whitespace ();
   old_locus = gfc_current_locus;
+
+  /* If c isn't [a-z], then return immediately.  */
+  c = gfc_peek_ascii_char ();
+  if (!ISALPHA(c))
+    return MATCH_NO;
+
   type_param_spec_list = NULL;
 
   if (match_derived_type_spec (ts) == MATCH_YES)
@@ -2099,6 +2105,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 ec17df111c8c136a04572c0afff25325d0a281ef..5191a6b017c6c23862e68ff05bba51f9c0d28b5a 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-07  David Malcolm  <dmalcolm@redhat.com>
 
        PR c++/81610
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