This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [Patch, fortran] PR35810 - [TR 15581 / F2003] Automatic reallocation on assignment to allocatable variables
- From: Tobias Burnus <burnus at net-b dot de>
- To: Paul Richard Thomas <paul dot richard dot thomas at gmail dot com>
- Cc: Dominique Dhumieres <dominiq at lps dot ens dot fr>, fortran at gcc dot gnu dot org, gcc-patches <gcc-patches at gcc dot gnu dot org>
- Date: Sun, 21 Nov 2010 09:15:22 +0100
- Subject: Re: [Patch, fortran] PR35810 - [TR 15581 / F2003] Automatic reallocation on assignment to allocatable variables
- References: <AANLkTim7ChiQB+Hzf-Pit4GSRh7idofZA5doH5-nxhj9@mail.gmail.com>
Dear Paul,
Paul Richard Thomas wrote:
Not only does the patch bootstrap and regtest but it runs Polyhedron
correctly this time! OK for trunk?
Reading the code I think you mishandle kind=4 characters as you seem to
allocate only (char-length) bytes instead of (storage size of an
element)*(char length). However, when I tries it, I already get a
segfault with kind=1 characters:
character(kind=1, len=100), allocatable, dimension(:) :: str
str = [ "abc" ]
end
Ditto for character kind=4.
Additionally, you have lots of checks of the form:
+ if (!expr1->symtree->n.sym->attr.allocatable
+ || (expr1->ref && expr1->ref->type == REF_ARRAY
Those fail if you work with derived types such as:
type t
integer, allocatable :: a(:)
end type t
type(t) :: x
x%a= [1,2,3]
print *, x%a
x%a = [1]
print * ,x%a
end
As "x" is not allocatable, only "x%a" is. For the attribute, you should
could use gfc_expr_attr (), for the last component ref, you need to use
a manual for loop, unless I missed a helper function.
Otherwise, the patch looks good.
Tobias