[Patch, fortran] PR50981 correctly handle absent arrays as actual argument to elemental procedures

Mikael Morin mikael.morin@sfr.fr
Sun Feb 12 18:55:00 GMT 2012


Hello,

there was no specific handling for absent arrays passed as argument to 
elemental procedures.  So, because of scalarisation, we were passing an 
array element reference of a NULL pointer which was failing.

These patches add a conditional to pass NULL when the data pointer is 
NULL.  Normally, it would be best to have the conditional moved out of 
the loop.  However, for fear of combinatorial explosion and to avoid 
extra complexity when there is more than one optional argument, I have 
left the conditional in the loop, and hope that the middle-end will do 
the right thing.


The first patch moves the recently added `can_be_null_ref' field out of 
the scalar-only part of the data union in the gfc_ss_info struct, and 
also moves the code setting it out of the scalar-only block in 
gfc_walk_elemental_function_args.
The second patch adds the conditional in gfc_conv_procedure_call.  We 
need to make sure to save the value of se->ss, as gfc_conv_tmp_array_ref 
or gfc_conv_expr_reference will advance it to the next in the chain. 
Otherwise nothing special.

Regression tested on x86_64-unknown-freebsd9.0.  OK for trunk?

Mikael


-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: elemental_optional_array-1.CL
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20120212/1c7c3ebd/attachment.ksh>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: elemental_optional_array-1.patch
Type: text/x-patch
Size: 2732 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20120212/1c7c3ebd/attachment.bin>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: elemental_optional_array-2.CL
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20120212/1c7c3ebd/attachment-0001.ksh>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: elemental_optional_array-2.patch
Type: text/x-patch
Size: 1975 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20120212/1c7c3ebd/attachment-0001.bin>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: elemental_optional_array-tests.CL
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20120212/1c7c3ebd/attachment-0002.ksh>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: elemental_optional_array-tests.patch
Type: text/x-patch
Size: 1587 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20120212/1c7c3ebd/attachment-0002.bin>


More information about the Fortran mailing list