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

Tobias Burnus burnus@net-b.de
Thu Apr 11 22:29:00 GMT 2013


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



More information about the Fortran mailing list