[Patch, fortran] PR25084, PR20852, PR25085, PR25086 & PR25416 - assumed character length functions

Paul Thomas paulthomas2@wanadoo.fr
Wed Jan 25 17:41:00 GMT 2006


:ADDPATCH fortran:

This patch addresses itself to some of the issues with assumed character 
length functions.

There are two parts:

One is trivial and implements the constraints and conditions of 5.1.1.5 
of the standard. I hovered over adding an assumed charlen attribute and 
using check_conflict to implement this but went for implementation in 
resolve.c, on grounds of clarity and simplicity.

The other is less trivial but is straightforward. The first part of the 
patch prevents a function call from being converted that has a *-charlen 
reference, except in the legal case of intrinsics like SPREAD. Since all 
such cases have the source as the first actual argument, the actual 
argument character length is used to provide the backend_decl for
the result. Being unambiguous, no check is made for the name of the 
function. This part of the patch cures the ICE in PR25416.

The first test checks the new constraints and conditions, the second 
checks that the second part of the patch fixes PR25416 and the third 
makes sure that the bits that should work do so.

I notice that, according to B.2 of the standard, assumed character 
length functions are obsolescent in F95. Is it worth a warning if std=f95?

Regtested on FC3/Athlon:  OK for mainline and 4.1?

Paul   

2005-01-25  Paul Thomas  <pault@gcc.gnu.org>

    PR fortran/25084
    PR fortran/20852
    PR fortran/25085
    PR fortran/25086
    * resolve.c (resolve_function): Declare a gfc_symbol to replace the 
references
    through the symtree to the symbol associated with the function 
expresion. Give
    error on reference to an assumed character length function is 
defined in an
    interface or an external function that is not a dummy argument.
    (resolve_symbol): Give error if an assumed character length function 
is array-
    valued, pointer-valued, pure or recursive.

    PR fortran/25416
    * trans-expr.c (gfc_conv_function_call): The above patch to 
resolve.c prevents
    any assumed character length function call from getting here, except 
intrinsics
    such as SPREAD. In this case, ensure that no segfault occurs from 
referencing
    non-existent charlen->length->expr_type and provide a backend_decl 
for the
    charlen from the charlen of the first actual argument.

2005-01-25  Paul Thomas  <pault@gcc.gnu.org>

    PR fortran/25084
    PR fortran/20852
    PR fortran/25085
    PR fortran/25086
    * gfortran.dg/assumed_charlen_function_1.f90: New test for constraints.
    * gfortran.dg/assumed_charlen_function_3.f90: New test for what 
should compile.

    PR fortran/25416
    * gfortran.dg/assumed_charlen_function_2.f90: New test for *-charlen 
in SPREAD.
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: assumed_charlen.diff
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20060125/1082296e/attachment.ksh>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: assumed_charlen_function_1.f90
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20060125/1082296e/attachment.f90>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: assumed_charlen_function_2.f90
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20060125/1082296e/attachment-0001.f90>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: assumed_charlen_function_3.f90
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20060125/1082296e/attachment-0002.f90>


More information about the Gcc-patches mailing list