This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
Re: [Patch, Fortran] PR56845 - Fix setting of vptr of CLASS(...),SAVE,ALLOCATABLE
- From: Tobias Burnus <burnus at net-b dot de>
- To: Janus Weil <janus at gcc dot gnu dot org>
- Cc: gcc patches <gcc-patches at gcc dot gnu dot org>, gfortran <fortran at gcc dot gnu dot org>
- Date: Fri, 12 Apr 2013 00:29:13 +0200
- Subject: Re: [Patch, Fortran] PR56845 - Fix setting of vptr of CLASS(...),SAVE,ALLOCATABLE
- References: <5161B4E2 dot 1030206 at net-b dot de> <CAKwh3qiRoau9v0zvM1MHCNwJ1J-9Qo53_a_msQ7pmOZbhEfTyA at mail dot gmail dot com>
Am 12.04.2013 00:05, schrieb Janus Weil:
Just one minor nit:
+ if (sym->ts.type == BT_CLASS && TREE_STATIC (sym->backend_decl)
+ && CLASS_DATA (sym)->attr.allocatable)
I'd find it somewhat clearer to check for "sym->attr.save" instead of
"TREE_STATIC (sym->backend_decl)", but that may be a matter of taste.
I think there was a test-suite failure when I tried it. In any case,
variables might be in static memory even if attr.save is not set:
- Module variables
- Variables of the main program
- Local variables of constant size (instead of allocating them on the
stack), depending on their size
- All local variables with -fno-automatic, which implies SAVE
- If "SAVE" has been specified for the scoping unit
(For the first three items, a static initialization is not required, it
could also be done after the declaration.) Instead of taking care of all
those, I think it is simpler to use TREE_STATIC ;-)
Oh, and can you remind me why this does not need to be done for pointers?
They are in undefined state. Thus, they need to be nullified, pointer
associated or allocated before they can be used. All those actions will
set both the data and the vptr component.
With the new array descriptor, one actually should (could?) set some
elements, e.g. attribute = pointer, version = 1, and (at least for
non-CLASS) "type = ...". Then, one does not touch those components for
ptr-assoc/allocate.
OK as is?
Tobias