This is the mail archive of the fortran@gcc.gnu.org mailing list for the GNU Fortran project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [Patch, Fortran] PR56845 - Fix setting of vptr of CLASS(...),SAVE,ALLOCATABLE


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]