[Patch, fortran] PR29642 - Fortran 2003: VALUE Attribute (pass by value)

Paul Thomas paulthomas2@wanadoo.fr
Tue Nov 14 14:33:00 GMT 2006


:ADDPATCH fortran:

The attached patch supplies an implementation of the VALUE attribute and 
three associated testscases.

The patch consists of a repetition of the code that implements other 
attributes, such as TARGET  or VOLATILE.  In addition, two small changes 
are needed to pass by value (gfc_conv_function_call) and to treat a 
dummy as having been passed by value (gfc_conv_variable and gfc_sym_type).

The first test case checks the functionality of the patch; that a 
reasonable sprinkling of types and kinds are passed correctly, that it 
is the value that is passed and the modules do the right thing.  The 
second testcase check that -std=F2003 is applied.  The third checks the 
constraints on the value attribute.  Allocatable has been included in 
the conflicts but I could not get it to do anything because the compiler 
either grumbled that the variable was not a scalar or that the 
allocatable attribute had to be applied to an array.

A patch for %VAL, %LOC and %REF is on its way in the next 24hours.  It 
turned out that they are completely separate from each other, even 
though, at first sight, the functionality is not disimilar.

Regtested on Cygwin_NT/amd64 - OK for trunk?

Paul

2006-11-14 Paul Thomas <pault@gcc.gnu.org>

    PR fortran/29642
    * trans-expr.c (gfc_conv_variable): A character expression with
    the VALUE attribute needs an address expression; otherwise all
    other expressions with this attribute must not be dereferenced.
    (gfc_conv_function_call): Pass expressions with the VALUE
    attribute by value, using gfc_conv_expr.
    * symbol.c (check_conflict): Add strings for INTENT OUT, INOUT
    and VALUE.  Apply all the constraints associated with the VALUE
    attribute.
    (gfc_add_value): New function.
    (gfc_copy_attr): Call it for VALUE attribute.
    * decl.c (match_attr_spec): Include the VALUE attribute.
    (gfc_match_value): New function.
    * dump-parse-tree.c (gfc_show_attr): Include VALUE.
    * gfortran.h : Add value to the symbol_attribute structure and
    add a prototype for gfc_add_value
    * module.c (mio_internal_string): Include AB_VALUE in enum.
    (attr_bits): Provide the VALUE string for it.
    (mio_symbol_attribute): Read or apply the VLUE attribute.
    * trans-types.c (gfc_sym_type): Variables with the VLAUE
    attribute are not passed by reference!
    * resolve.c (was_declared): Add value to those that return 1.
    * match.h : Add prototype for gfc_match_public.
    * parse.c (decode_statement): Try to match a VALUE statement.


2006-11-14 Paul Thomas <pault@gcc.gnu.org>

    PR fortran/29642
    * gfortran.dg/value_1.f90 : New test.
    * gfortran.dg/value_2.f90 : New test.
    * gfortran.dg/value_2.f90 : New test.



-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: value.diff
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20061114/aa812876/attachment.ksh>


More information about the Fortran mailing list