On Tue, 19 Oct 2021 16:49:02 +0200 Tobias Burnus <tob...@codesourcery.com> wrote:
> On 16.10.21 20:54, Jan Hubicka wrote: > > I wrote: > >> Fortran has for a long time 'character(len=5), allocatable" or > >> "character(len=*)". In the first case, the "5" can be ignored as both > >> caller and callee know the length. In the second case, the length is > >> determined by the argument, but it cannot be changed. > >> > >> Since a not-that-short while, 'len=:' together with allocatable/pointer > >> is supported. > >> > >> In the latter case, the value can be change when the array > >> association/allocation is changed. > >> ... > >> + if (!sym->ts.u.cl->length > >> + && ((sym->attr.allocatable && sym->attr.target) > >> + || sym->attr.pointer)) > >> + spec[spec_len++] = '.'; > >> + if (!sym->ts.u.cl->length && sym->attr.allocatable) > >> + spec[spec_len++] = 'w'; > >> + else > >> + spec[spec_len++] = 'R'; > > Also escaping is quite important bit of information so it would be > > good to figure out if it really can escape rather than playing safe. > > The pointer to the string length variable itself does not escape, > only its integer string value: > > subroutine foo(x) > character(len=:), pointer :: x > character(len=:), pointer :: y > y => x > has in the dump: > .y = *_x; > y = (character(kind=1)[1:.y] *) *x; > > Thus, 'w' can always be used. > > Committed as obvious as r12-4511-gff0eec94e87dfb7dc387f120ca5ade2707aecf50 I guess we don't have intrinsics with allocatable or pointer character types? Just asking because this fix went to trans-types.c::create_fn_spec but we also construct fn spec strings in trans-intrinsic.c::intrinsic_fnspec In the former, the if (spec_len < sizeof (spec)) looks like it's suboptimal, I'd rather not have this went unnoticed? Maybe it would be worthwhile to have just one fnspec generator which is used in both spots? thanks,