[Patch, Fortran] PR55763 - improve init-data checks for pointers

Tobias Burnus burnus@net-b.de
Fri Jan 4 12:51:00 GMT 2013


Fortran 2008 allows:
    integer :: pointer => init_data
and
   type t
      integer :: pointer => init_data
   end type t

The current check in gfc_check_assign_symbol was only called for former 
and for constructors, but not for the type definition. Additionally, 
BT_CLASS wasn't handled. I also improved the error location.



The patch has a downside: One gets some messages twice or trice: Once 
for resolving the type declaration ("type t") and then for resolving the 
default initialization via
    gfc_traverse_ns (ns, resolve_values);

Currently, that's unavoidable as one cannot trivially distinguish 
between a user-supplied "sym->value" and the default constructor. If you 
think that this is a problem, one can change it, e.g. by setting a 
sym->attr.value_is_default_init.


Build and regtested on x86-64-gnu-linux.
OK for the trunk?

Tobias

PS: For CLASS pointers, there will be an ICE if one tries to associate a 
variable to them; that's unchanged by this patch.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pointer-init-err-v2.diff
Type: text/x-patch
Size: 12471 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20130104/95eb22ba/attachment.bin>


More information about the Fortran mailing list