[PATCH] PR fortran/65173 -- kill off old_cl_list from gfc_namespace.
Steve Kargl
sgk@troutmask.apl.washington.edu
Thu Dec 8 02:14:00 GMT 2016
All,
The attach patch fixes an ICE from a testcase in PR fortran/65173.
First, I draw your attention to the comment in gfortran.h above
the definition of gfc_charlen. It is
/* Character length structures hold the expression that gives the
length of a character variable. We avoid putting these into
gfc_typespec because doing so prevents us from doing structure
copies and forces us to deallocate any typespecs we create, as well
as structures that contain typespecs. They also can have multiple
character typespecs pointing to them.
These structures form a singly linked list within the current
namespace and are deallocated with the namespace. It is possible to
end up with gfc_charlen structures that have nothing pointing to them. */
The last paragraph is important, here. So, the problematic code was
program foo
type t
character, allocatable :: z1(:), z1(:)
end type t
end program foo
gfortran rightly rejected this code and issues an appropriate error.
However, when parse.c (reject_statement) tries to cleanup the parsing
of the invalid statement, it manages to corrupt the namespace's cl_list.
How? Well, that's a good question on which I wasted too much time given
the last paragraph in the gfortran.h comment. Removing the manipulations
of the cl_list in reject_statement, then revealed that old_cl_list is
unneeded. So, I give unto you
2016-12-07 Steven G. Kargl <kargl@gcc.gnu.org>
PR fortran/65173
* gfortran.h (gfc_namespace): Remove old_cl_list member.
* parse.c (use_modules, next_statement): old_cl_list is gone.
(clear_default_charlen): Remove no longer used function.
(reject_statement): Do not try to clean up gfc_charlen structure(s)
that may have been added to a cl_list list.
* symbol.c (gfc_new_charlen): old_cl_list structure is gone.
2016-12-07 Steven G. Kargl <kargl@gcc.gnu.org>
PR fortran/65173
* gfortran.dg/misplaced_implicit_character.f90: Adjust errors.
* gfortran.dg/pr65173.f90: New test.
The patch is attached and regression tested on x86_64-*-freebsd.
OK to commit?
--
Steve
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pr65173.diff
Type: text/x-diff
Size: 4601 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20161208/e16891b1/attachment.bin>
More information about the Gcc-patches
mailing list