diff options
author | Paul Thomas <pault@gcc.gnu.org> | 2006-12-03 07:18:22 +0000 |
---|---|---|
committer | Paul Thomas <pault@gcc.gnu.org> | 2006-12-03 07:18:22 +0000 |
commit | 06469efd1a409d723093cfaa75ab9d39653e6463 (patch) | |
tree | 2cc0f500bf05264d75beb5ac0011e36ce0619792 /gcc/fortran/decl.c | |
parent | 3c5e8e4492a4f360800bfc4d3965a5a85c230a08 (diff) | |
download | gcc-06469efd1a409d723093cfaa75ab9d39653e6463.zip gcc-06469efd1a409d723093cfaa75ab9d39653e6463.tar.gz gcc-06469efd1a409d723093cfaa75ab9d39653e6463.tar.bz2 |
re PR fortran/29642 (Fortran 2003: VALUE Attribute (call by value not call by reference for actual arguments))
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.
From-SVN: r119461
Diffstat (limited to 'gcc/fortran/decl.c')
-rw-r--r-- | gcc/fortran/decl.c | 66 |
1 files changed, 65 insertions, 1 deletions
diff --git a/gcc/fortran/decl.c b/gcc/fortran/decl.c index 25fa6b5..46c49ba 100644 --- a/gcc/fortran/decl.c +++ b/gcc/fortran/decl.c @@ -2117,7 +2117,7 @@ match_attr_spec (void) DECL_ALLOCATABLE = GFC_DECL_BEGIN, DECL_DIMENSION, DECL_EXTERNAL, DECL_IN, DECL_OUT, DECL_INOUT, DECL_INTRINSIC, DECL_OPTIONAL, DECL_PARAMETER, DECL_POINTER, DECL_PRIVATE, DECL_PUBLIC, DECL_SAVE, - DECL_TARGET, DECL_VOLATILE, DECL_COLON, DECL_NONE, + DECL_TARGET, DECL_VALUE, DECL_VOLATILE, DECL_COLON, DECL_NONE, GFC_DECL_END /* Sentinel */ } decl_types; @@ -2140,6 +2140,7 @@ match_attr_spec (void) minit (", public", DECL_PUBLIC), minit (", save", DECL_SAVE), minit (", target", DECL_TARGET), + minit (", value", DECL_VALUE), minit (", volatile", DECL_VOLATILE), minit ("::", DECL_COLON), minit (NULL, DECL_NONE) @@ -2261,6 +2262,9 @@ match_attr_spec (void) case DECL_TARGET: attr = "TARGET"; break; + case DECL_VALUE: + attr = "VALUE"; + break; case DECL_VOLATILE: attr = "VOLATILE"; break; @@ -2378,6 +2382,15 @@ match_attr_spec (void) t = gfc_add_target (¤t_attr, &seen_at[d]); break; + case DECL_VALUE: + if (gfc_notify_std (GFC_STD_F2003, + "Fortran 2003: VALUE attribute at %C") + == FAILURE) + t = FAILURE; + else + t = gfc_add_value (¤t_attr, NULL, &seen_at[d]); + break; + case DECL_VOLATILE: if (gfc_notify_std (GFC_STD_F2003, "Fortran 2003: VOLATILE attribute at %C") @@ -4051,6 +4064,57 @@ syntax: match +gfc_match_value (void) +{ + gfc_symbol *sym; + match m; + + if (gfc_notify_std (GFC_STD_F2003, + "Fortran 2003: VALUE statement at %C") + == FAILURE) + return MATCH_ERROR; + + if (gfc_match (" ::") == MATCH_NO && gfc_match_space () == MATCH_NO) + { + return MATCH_ERROR; + } + + if (gfc_match_eos () == MATCH_YES) + goto syntax; + + for(;;) + { + m = gfc_match_symbol (&sym, 0); + switch (m) + { + case MATCH_YES: + if (gfc_add_value (&sym->attr, sym->name, + &gfc_current_locus) == FAILURE) + return MATCH_ERROR; + goto next_item; + + case MATCH_NO: + break; + + case MATCH_ERROR: + return MATCH_ERROR; + } + + next_item: + if (gfc_match_eos () == MATCH_YES) + break; + if (gfc_match_char (',') != MATCH_YES) + goto syntax; + } + + return MATCH_YES; + +syntax: + gfc_error ("Syntax error in VALUE statement at %C"); + return MATCH_ERROR; +} + +match gfc_match_volatile (void) { gfc_symbol *sym; |