For intrinsic routines, called in libraries, the prototype is created from
the call via gfc_get_symbol_for_expr. For the actual arguments, it calls
gfc_copy_formal_args_intr which already ensures that the ts.u.cl is freshly
allocated.
This commit now ensures the same for character-returning functions.
PR fortran/118441
gcc/fortran/ChangeLog:
* trans-intrinsic.cc (gfc_get_symbol_for_expr): Use
gfc_new_charlen for character-returning functions.
gcc/testsuite/ChangeLog:
* gfortran.dg/gomp/intrinsic_pack_7.f90: New test.
sym = gfc_new_symbol (expr->value.function.name, NULL);
sym->ts = expr->ts;
+ if (sym->ts.type == BT_CHARACTER)
+ sym->ts.u.cl = gfc_new_charlen (gfc_current_ns, NULL);
sym->attr.external = 1;
sym->attr.function = 1;
sym->attr.always_explicit = 1;
--- /dev/null
+! PR fortran/118441
+
+subroutine sub(s)
+ character(len=*), intent(inout) :: s(:)
+ integer :: n
+ s( : ) = s(:) ! OK
+ n = count(s(:) /= '')
+ s(1:n) = pack (s(:), mask=(s(:) /= '')) ! ICE
+end subroutine sub