https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122433
kargls at comcast dot net changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |kargls at comcast dot net
--- Comment #1 from kargls at comcast dot net ---
(In reply to Damian Rouson from comment #0)
> $ cat neuron_m.f90
> module neuron_m
> implicit none
>
> type string_t
> character(len=:), allocatable :: string_
> end type
>
> type neuron_t(k)
> integer, kind :: k = kind(1.)
> real(k) bias_
> type(neuron_t(k)), allocatable :: next
> end type
>
> contains
> recursive function from_json(neuron_lines, start) result(neuron)
> type(string_t) neuron_lines(:)
> integer start
> type(neuron_t) neuron
> character(len=:), allocatable :: line
> line = neuron_lines(start+1)%string_
> read(line(index(line, ":")+1:), fmt=*) neuron%bias_
> line = adjustr(neuron_lines(start+3)%string_)
> if (line(len(line):) == ",") neuron%next = from_json(neuron_lines,
> start+4)
If I change this to 'if (line(len(line):) == ",") stop 1', the code
compiles. I suspect you also tried
if (line(len(line):) == ",") then
neuron%next = from_json(neuron_lines, start+4)
end if
which leads to
% gfcx -c a.f90
a.f90:26:24:
26 | neuron%next = from_json(neuron_lines, start+4)
| 1
Error: 'next' at (1) is not a member of the 'Pdtneuron_t_4' structure
The IF conditional is likely parse correctly, but the error your
seeing is related to the issue with in finding 'next'.
>
> $ gfortran -c neuron_m.f90
> neuron_m.f90:23:34:
>
> 23 | if (line(len(line):) == ",") neuron%next =
> from_json(neuron_lines, start+4)
> | 1
> Error: Syntax error in IF-clause after (1)
> -----
> On a related note, it appears that gfortran 16 requires the "recursive"
> keyword above. Fortran 2018 removed the requirement for the keyword.
This is https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101632
I even submitted a patch (which had some regressions that I
never tracked downed).
While I generally frown on individuals second guessing J3 in
comp.lang.fortran or fortran-lang groups, this is a case where I
think J3 made a mistake. Yes, J3 will say internal implementation
details are not their concern, but making everything recursive
seems to be a fun way to blow out the stack.