void gfc_free_association_list (gfc_association_list *);
/* resolve.cc */
+void gfc_resolve_symbol (gfc_symbol *);
void gfc_expression_rank (gfc_expr *);
bool gfc_op_rank_conformable (gfc_expr *, gfc_expr *);
bool gfc_resolve_ref (gfc_expr *);
else
derived = base->expr->ts.u.derived;
+ /* A use associated derived type is resolvable during parsing. */
+ if (derived && derived->attr.use_assoc && !gfc_current_ns->resolved)
+ gfc_resolve_symbol (derived);
+
if (op == INTRINSIC_USER)
{
gfc_symtree* tb_uop;
goto assocListError;
}
}
+ else if (newAssoc->target->ts.type == BT_UNKNOWN
+ && newAssoc->target->expr_type == EXPR_OP)
+ {
+ /* This will work for sure if the operator is type bound to a use
+ associated derived type. */
+ gfc_expr *tmp =gfc_copy_expr (newAssoc->target);
+ if (gfc_extend_expr (tmp) == MATCH_YES)
+ gfc_replace_expr (newAssoc->target, tmp);
+ else
+ gfc_free_expr (tmp);
+ }
/* The `variable' field is left blank for now; because the target is not
yet resolved, we can't use gfc_has_vector_subscript to determine it
}
+void gfc_resolve_symbol (gfc_symbol *sym)
+{
+ resolve_symbol (sym);
+ return;
+}
+
+
/************* Resolve DATA statements *************/
static struct
--- /dev/null
+! { dg-do compile }
+! { dg-options "-fdump-tree-original" }
+!
+! Test the fix for PR123352, which failed as shown. The operator in the first
+! selector was not being resolved and so 'op_foo' did not have a type.
+!
+! Contributed by Damian Rouson <damian@archaeologic.codes>
+!
+module tensors_m
+ implicit none
+
+ type foo_t
+ contains
+ generic :: operator(.op.) => op
+ procedure op
+ procedure f
+ end type
+
+contains
+
+ type(foo_t) function op(self)
+ class(foo_t), intent(in) :: self
+ op = self
+ end function
+
+ integer function f(self)
+ class(foo_t) self
+ f = 42
+ end function
+
+end module
+
+ use tensors_m
+ implicit none
+ type(foo_t) foo
+
+ associate(op_foo => .op. foo)
+ associate(op_foo_f => op_foo%f()) ! Error: Invalid association target at (1)
+ print *, op_foo_f
+ end associate
+ end associate ! Error: Expecting END PROGRAM statement at (1)
+end
+! { dg-final { scan-tree-dump-times "struct foo_t op_foo;" 1 "original" } }
+! { dg-final { scan-tree-dump-times "integer.kind=4. op_foo_f;" 1 "original" } }