This is already supported by a large number of compilers (e.g. sunf95, NAG f95, ifort, g95). gfortran gives: Syntax error in data declaration Example: subroutine foo(i) implicit none integer, value :: i print *, i end subroutine foo From the Fortran 2003 standard: "5.1.2.15 VALUE attribute The VALUE attribute specifies a type of argument association (12.4.1.2) for a dummy argument." And in "12.4.1.2 Actual arguments associated with dummy data objects" "If the dummy argument has the VALUE attribute it becomes associated with a definable anonymous data object whose initial value is that of the actual argument. Subsequent changes to the value or definition status of the dummy argument do not affect the actual argument." "NOTE 12.22 Fortran argument association is usually similar to call by reference and call by value-result. If the VALUE attribute is specified, the effect is as if the actual argument is assigned to a temporary, and the temporary is then argument associated with the dummy argument. The actual mechanism by which this happens is determined by the processor."
Confirmed Paul
Created attachment 12608 [details] Implementation of VALUE and three testcases This patch is regtesting as I write; I have to leave right now, so I will not see the confirmation until tomorrow. I will submit in the next 24hours. Paul
Subject: Bug number PR29642 A patch for this bug has been added to the patch tracker. The mailing list url for the patch is http://gcc.gnu.org/ml/gcc-patches/2006-11/msg00923.html
Subject: Bug 29642 Author: pault Date: Sun Dec 3 07:18:22 2006 New Revision: 119461 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=119461 Log: 2006-12-03 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. (resolve_symbol): Value attribute requires dummy attribute. * match.h : Add prototype for gfc_match_public. * parse.c (decode_statement): Try to match a VALUE statement. 2006-12-03 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_3.f90 : New test. * gfortran.dg/value_4.f90 : New test. * gfortran.dg/value_4.c : Called from value_4.f90. Added: trunk/gcc/testsuite/gfortran.dg/value_1.f90 trunk/gcc/testsuite/gfortran.dg/value_2.f90 trunk/gcc/testsuite/gfortran.dg/value_3.f90 trunk/gcc/testsuite/gfortran.dg/value_4.c trunk/gcc/testsuite/gfortran.dg/value_4.f90 Modified: trunk/gcc/fortran/ChangeLog trunk/gcc/fortran/decl.c trunk/gcc/fortran/dump-parse-tree.c trunk/gcc/fortran/gfortran.h trunk/gcc/fortran/match.h trunk/gcc/fortran/module.c trunk/gcc/fortran/parse.c trunk/gcc/fortran/resolve.c trunk/gcc/fortran/symbol.c trunk/gcc/fortran/trans-expr.c trunk/gcc/fortran/trans-types.c trunk/gcc/testsuite/ChangeLog
Fixed in 4.3 Paul