https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99139
kargl at gcc dot gnu.org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |kargl at gcc dot gnu.org
Last reconfirmed| |2021-02-17
Ever confirmed|0 |1
Status|UNCONFIRMED |NEW
Priority|P3 |P4
--- Comment #2 from kargl at gcc dot gnu.org ---
Fixes problem with original code. Not regression tested.
diff --git a/gcc/fortran/match.c b/gcc/fortran/match.c
index 2df6191d7e6..eb51b9905da 100644
--- a/gcc/fortran/match.c
+++ b/gcc/fortran/match.c
@@ -6634,6 +6639,18 @@ gfc_match_select_rank (void)
gfc_current_ns = gfc_build_block_ns (ns);
m = gfc_match (" %n => %e", name, &expr2);
+
+ /* If expr2 corresponds to an implicitly typed variable, then the actual
+ type of the variable may not have been resolved. Set it here. */
+ if (!gfc_current_ns->seen_implicit_none
+ && expr2->expr_type == EXPR_VARIABLE
+ && expr2->ts.type == BT_UNKNOWN
+ && expr2->symtree && expr2->symtree->n.sym)
+ {
+ gfc_set_default_type (expr2->symtree->n.sym, 0, gfc_current_ns);
+ expr2->ts.type = expr2->symtree->n.sym->ts.type;
+ }
+
if (m == MATCH_YES)
{
expr1 = gfc_get_expr ();