|| (e->expr_type == EXPR_FUNCTION && e->symtree->n.sym))
{
for (param = type_param_spec_list; param; param = param->next)
- if (strcmp (e->symtree->n.sym->name, param->name) == 0)
+ if (!strcmp (e->symtree->n.sym->name, param->name))
break;
if (param && param->expr)
{
copy = gfc_copy_expr (param->expr);
- *e = *copy;
- free (copy);
+ gfc_replace_expr (e, copy);
/* Catch variables declared without a value expression. */
if (e->expr_type == EXPR_VARIABLE && e->ts.type == BT_PROCEDURE)
e->ts = e->symtree->n.sym->ts;
gfc_expr *e;
e = gfc_copy_expr (c1->as->lower[i]);
gfc_insert_kind_parameter_exprs (e);
- gfc_simplify_expr (e, 1);
- gfc_free_expr (c2->as->lower[i]);
- c2->as->lower[i] = e;
+ if (gfc_simplify_expr (e, 1))
+ gfc_replace_expr (c2->as->lower[i], e);
+ else
+ gfc_free_expr (e);
e = gfc_copy_expr (c1->as->upper[i]);
gfc_insert_kind_parameter_exprs (e);
- gfc_simplify_expr (e, 1);
- gfc_free_expr (c2->as->upper[i]);
- c2->as->upper[i] = e;
+ if (gfc_simplify_expr (e, 1))
+ gfc_replace_expr (c2->as->upper[i], e);
+ else
+ gfc_free_expr (e);
}
c2->attr.pdt_array = 1;
gfc_expr *e;
e = gfc_copy_expr (c1->ts.u.cl->length);
gfc_insert_kind_parameter_exprs (e);
- gfc_simplify_expr (e, 1);
- gfc_free_expr (c2->ts.u.cl->length);
- c2->ts.u.cl->length = e;
+ if (gfc_simplify_expr (e, 1))
+ gfc_replace_expr (c2->ts.u.cl->length, e);
+ else
+ gfc_free_expr (e);
c2->attr.pdt_string = 1;
}
if (!s)
gfc_insert_parameter_exprs (c2->initializer,
type_param_spec_list);
- gfc_simplify_expr (params->expr, 1);
+ gfc_simplify_expr (c2->initializer, 1);
}
}
--- /dev/null
+! { dg-do compile }
+! { dg-options "-fdump-tree-original" }
+!
+! Check the fix for PR115315.f90 in which line 14 caused the error,
+! "Argument of IACHAR at (1) must be of length one".
+!
+! Contributed by David Binderman <dcb314@hotmail.com>
+!
+ call p2
+contains
+ subroutine p2
+ type t1(n1,n2)
+ integer,kind :: n1,n2
+ integer :: c2(iachar('ABCDEFGHIJ'(n1:n2)))
+ end type
+
+ type(t1(4,4)) :: x
+ if (char (size (x%c2, 1)) .ne. "D") then
+ print *, "Wrong!"
+ else
+ print *, "Right"
+ endif
+ end
+end
+! { dg-final { scan-tree-dump-times "Wrong" 0 "original" } }
+! { dg-final { scan-tree-dump-times "Right" 1 "original" } }