diff options
Diffstat (limited to 'gcc/fortran/primary.c')
-rw-r--r-- | gcc/fortran/primary.c | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/gcc/fortran/primary.c b/gcc/fortran/primary.c index 8fe129457b4..ad569fcf6b6 100644 --- a/gcc/fortran/primary.c +++ b/gcc/fortran/primary.c @@ -1912,6 +1912,8 @@ gfc_match_rvalue (gfc_expr ** result) gfc_expr *e; match m, m2; int i; + gfc_typespec *ts; + bool implicit_char; m = gfc_match_name (name); if (m != MATCH_YES) @@ -2156,10 +2158,22 @@ gfc_match_rvalue (gfc_expr ** result) if (m2 != MATCH_YES) { + /* Try to figure out whether we're dealing with a character type. + We're peeking ahead here, because we don't want to call + match_substring if we're dealing with an implicitly typed + non-character variable. */ + implicit_char = false; + if (sym->ts.type == BT_UNKNOWN) + { + ts = gfc_get_default_type (sym,NULL); + if (ts->type == BT_CHARACTER) + implicit_char = true; + } + /* See if this could possibly be a substring reference of a name that we're not sure is a variable yet. */ - if ((sym->ts.type == BT_UNKNOWN || sym->ts.type == BT_CHARACTER) + if ((implicit_char || sym->ts.type == BT_CHARACTER) && match_substring (sym->ts.cl, 0, &e->ref) == MATCH_YES) { |