[Patch, fortran] PR26891 - Automatic conversion for optional parameters of missing dummies

Paul Thomas paulthomas2@wanadoo.fr
Fri Mar 31 19:15:00 GMT 2006


:ADDPATCH fortran:

This patch fixes PR26891, in which missing, optional, dummy arguments 
cause a segfault when used as optional actual arguments.  The original 
involved intrinsic functions such as scan and verify but the same occurs 
for non-intrinsic functions too.

According to the standard:
__________________________

12.4.1.5 Restriction on dummy arguments not present.

.....

Except as noted in the list above, it may be supplied as an actual 
argument corresponding to an optional dummy argument, which is also 
considered not to be associated with an actual argument.

.....

The patch and the testcase are straightforward.  On the condition that 
the argument is both an optional dummy, not present and an optional 
formal argument, a null is passed for the expression and the 
string_length, if present.

This does not fix all intrinsic calls because some of the optional 
arguments are passed by value and zero does not always mean the same as 
the argument not being there.  However, ICEs no longer occur and most of 
the bad cases produce error messages.  This can only be fixed in the 
longer run by going through the intrinsics and making sure that they do 
the right thing; signalling a missing value with a null is about all 
that can be done.  It works in all cases for non-intrinsic functions.

I took the opportunity to prettify the code a bit in 
gfc_conv_intrinsic_function_args and gfc_conv_function_call; I reduced 
some of the deeply nested structure component references by introducing 
new gfc_exprs and a new gfc_symbol.

Regtested on FC3/Athlon.

OK for trunk and 4.1?

Paul

2005-03-31  Paul Thomas  <pault@gcc.gnu.org>

    PR fortran/26981
    * trans.h : Prototype for gfc_conv_missing_dummy.
    * trans-expr (gfc_conv_missing_dummy): New function
    (gfc_conv_function_call): Call it and tidy up some of the code.
    * trans-intrinsic (gfc_conv_intrinsic_function_args): The same.

2005-03-31  Paul Thomas  <pault@gcc.gnu.org>

    PR fortran/26981
    * gfortran.dg/missing_optional_dummy_1.f90: New test.




-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: submit.diff
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20060331/ab0e4c4a/attachment.ksh>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: missing_optional_dummy_1.f90
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20060331/ab0e4c4a/attachment.f90>


More information about the Gcc-patches mailing list