From: Steven G. Kargl Date: Wed, 7 Feb 2018 20:43:33 +0000 (+0000) Subject: re PR fortran/82049 (ICE with character(*),parameter array constructor) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=52b16cb3d48a328c9cdaa0ca55c151066ec65e4d;p=gcc.git re PR fortran/82049 (ICE with character(*),parameter array constructor) 2018-02-06 Steven G. Kargl 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 PR fortran/82049 * gfortran.dg/assumed_charlen_parameter.f90: New test. From-SVN: r257459 --- diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 4095c011ae0..4b2343c9ed7 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,9 @@ +2018-02-07 Steven G. Kargl + + 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 PR fortran/84115 diff --git a/gcc/fortran/match.c b/gcc/fortran/match.c index cf44fabb239..7bce34b56a0 100644 --- a/gcc/fortran/match.c +++ b/gcc/fortran/match.c @@ -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; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index ec17df111c8..5191a6b017c 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2018-02-07 Steven G. Kargl + + PR fortran/82049 + * gfortran.dg/assumed_charlen_parameter.f90: New test. + 2018-02-07 David Malcolm 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 index 00000000000..2653f1b127a --- /dev/null +++ b/gcc/testsuite/gfortran.dg/assumed_charlen_parameter.f90 @@ -0,0 +1,9 @@ +! { dg-do compile } +! PR fortran/82049 +! Original code contributed by John Harper +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