}
}
+static gfc_intrinsic_sym *
+copy_intrinsic_sym (const gfc_intrinsic_sym *src)
+{
+ gfc_intrinsic_sym *copy = XCNEW (gfc_intrinsic_sym);
+ gfc_intrinsic_arg *head = NULL;
+ gfc_intrinsic_arg **tail = &head;
+
+ *copy = *src;
+ for (const gfc_intrinsic_arg *arg = src->formal; arg; arg = arg->next)
+ {
+ *tail = XCNEW (gfc_intrinsic_arg);
+ **tail = *arg;
+ (*tail)->next = NULL;
+ tail = &(*tail)->next;
+ }
+ copy->formal = head;
+ return copy;
+}
+
/* Helper function for resolving the "mask" argument. */
static void
gfc_resolve_substring_charlen (source);
if (source->ts.type == BT_CHARACTER)
- check_charlen_present (source);
+ {
+ check_charlen_present (source);
+ f->value.function.isym = copy_intrinsic_sym (f->value.function.isym);
+ f->value.function.isym->formal->ts = source->ts;
+ }
f->ts = source->ts;
f->rank = source->rank + 1;
--- /dev/null
+! { dg-do compile }
+! { dg-options "-Os -fdump-tree-original-raw" }
+! { dg-final { scan-tree-dump {(?s)identifier_node strg: _gfortran_spread_char_scalar.*?function_type.*?prms: @[0-9]+.*?tree_list[^\n]*chan: @[0-9]+.*?tree_list[^\n]*chan: @[0-9]+.*?tree_list[^\n]*chan: @[0-9]+.*?tree_list[^\n]*chan: @[0-9]+.*?tree_list[^\n]*chan: @[0-9]+.*?tree_list[^\n]*chan: @8} "original" } }
+
+character(3) :: a = 'abc'
+
+associate (y => spread(trim(a), 1, 2) // 'd')
+ if (size(y) /= 2) stop 1
+end associate
+end