aboutsummaryrefslogtreecommitdiff
path: root/gcc/fortran/parse.c
diff options
context:
space:
mode:
authorDaniel Kraft <d@domob.eu>2008-08-31 12:00:30 +0200
committerDaniel Kraft <domob@gcc.gnu.org>2008-08-31 12:00:30 +0200
commite157f73660e50bd02f5c2c6d94624de70303e579 (patch)
treef1e34fc56018b9fd2a92bf9de5854b3ef33fc9bb /gcc/fortran/parse.c
parentf40751dd3417bc2b10d85a8f6afa3771c6de7101 (diff)
downloadgcc-e157f73660e50bd02f5c2c6d94624de70303e579.zip
gcc-e157f73660e50bd02f5c2c6d94624de70303e579.tar.gz
gcc-e157f73660e50bd02f5c2c6d94624de70303e579.tar.bz2
gfortran.h (enum gfc_statement): New entry `ST_GENERIC'.
2008-08-31 Daniel Kraft <d@domob.eu> * gfortran.h (enum gfc_statement): New entry `ST_GENERIC'. (struct gfc_tbp_generic): New type. (struct gfc_typebound_proc): Removed `target' and added union with `specific' and `generic' members; new members `overridden', `subroutine', `function' and `is_generic'. (struct gfc_expr): New members `derived' and `name' in compcall union member and changed type of `tbp' to gfc_typebound_proc. (gfc_compare_interfaces), (gfc_compare_actual_formal): Made public. * match.h (gfc_typebound_default_access): New global. (gfc_match_generic): New method. * decl.c (gfc_match_generic): New method. (match_binding_attributes): New argument `generic' and handle it. (match_procedure_in_type): Mark matched binding as non-generic. * interface.c (gfc_compare_interfaces): Made public. (gfc_compare_actual_formal): Ditto. (check_interface_1), (compare_parameter): Use new public names. (gfc_procedure_use), (gfc_search_interface): Ditto. * match.c (match_typebound_call): Set base-symbol referenced. * module.c (binding_generic): New global array. (current_f2k_derived): New global. (mio_typebound_proc): Handle IO of GENERIC bindings. (mio_f2k_derived): Record current f2k-namespace in current_f2k_derived. * parse.c (decode_statement): Handle GENERIC statement. (gfc_ascii_statement): Ditto. (typebound_default_access), (set_typebound_default_access): Removed. (gfc_typebound_default_access): New global. (parse_derived_contains): New default-access implementation and handle GENERIC statements encountered. * primary.c (gfc_match_varspec): Adapted to new gfc_typebound_proc structure and removed check for SUBROUTINE/FUNCTION from here. * resolve.c (extract_compcall_passed_object): New method. (update_compcall_arglist): Use it. (resolve_typebound_static): Adapted to new gfc_typebound_proc structure. (resolve_typebound_generic_call): New method. (resolve_typebound_call): Check target is a SUBROUTINE and handle calls to GENERIC bindings. (resolve_compcall): Ditto (check for target being FUNCTION). (check_typebound_override): Handle GENERIC bindings. (check_generic_tbp_ambiguity), (resolve_typebound_generic): New methods. (resolve_typebound_procedure): Handle GENERIC bindings and set new attributes subroutine, function and overridden in gfc_typebound_proc. (resolve_fl_derived): Ensure extended type is resolved before the extending one is. * st.c (gfc_free_statement): Fix bug with free'ing EXEC_COMPCALL's. * symbol.c (gfc_find_typebound_proc): Adapt for GENERIC changes. 2008-08-31 Daniel Kraft <d@domob.eu> * gfortran.dg/typebound_generic_1.f03: New test. * gfortran.dg/typebound_generic_2.f03: New test. * gfortran.dg/typebound_generic_3.f03: New test. From-SVN: r139822
Diffstat (limited to 'gcc/fortran/parse.c')
-rw-r--r--gcc/fortran/parse.c37
1 files changed, 18 insertions, 19 deletions
diff --git a/gcc/fortran/parse.c b/gcc/fortran/parse.c
index 9ec376a..c5493df 100644
--- a/gcc/fortran/parse.c
+++ b/gcc/fortran/parse.c
@@ -372,6 +372,7 @@ decode_statement (void)
break;
case 'g':
+ match ("generic", gfc_match_generic, ST_GENERIC);
match ("go to", gfc_match_goto, ST_GOTO);
break;
@@ -1195,6 +1196,9 @@ gfc_ascii_statement (gfc_statement st)
case ST_FUNCTION:
p = "FUNCTION";
break;
+ case ST_GENERIC:
+ p = "GENERIC";
+ break;
case ST_GOTO:
p = "GOTO";
break;
@@ -1691,21 +1695,10 @@ unexpected_eof (void)
}
-/* Set the default access attribute for a typebound procedure; this is used
- as callback for gfc_traverse_symtree. */
-
-static gfc_access typebound_default_access;
-
-static void
-set_typebound_default_access (gfc_symtree* stree)
-{
- if (stree->typebound && stree->typebound->access == ACCESS_UNKNOWN)
- stree->typebound->access = typebound_default_access;
-}
-
-
/* Parse the CONTAINS section of a derived type definition. */
+gfc_access gfc_typebound_default_access;
+
static bool
parse_derived_contains (void)
{
@@ -1730,6 +1723,8 @@ parse_derived_contains (void)
accept_statement (ST_CONTAINS);
push_state (&s, COMP_DERIVED_CONTAINS, NULL);
+ gfc_typebound_default_access = ACCESS_PUBLIC;
+
to_finish = false;
while (!to_finish)
{
@@ -1755,6 +1750,15 @@ parse_derived_contains (void)
seen_comps = true;
break;
+ case ST_GENERIC:
+ if (gfc_notify_std (GFC_STD_F2003, "Fortran 2003: GENERIC binding"
+ " at %C") == FAILURE)
+ error_flag = true;
+
+ accept_statement (ST_GENERIC);
+ seen_comps = true;
+ break;
+
case ST_FINAL:
if (gfc_notify_std (GFC_STD_F2003,
"Fortran 2003: FINAL procedure declaration"
@@ -1801,6 +1805,7 @@ parse_derived_contains (void)
}
accept_statement (ST_PRIVATE);
+ gfc_typebound_default_access = ACCESS_PRIVATE;
seen_private = true;
break;
@@ -1823,12 +1828,6 @@ parse_derived_contains (void)
pop_state ();
gcc_assert (gfc_current_state () == COMP_DERIVED);
- /* Walk the parsed type-bound procedures and set ACCESS_UNKNOWN attributes
- to PUBLIC or PRIVATE depending on seen_private. */
- typebound_default_access = (seen_private ? ACCESS_PRIVATE : ACCESS_PUBLIC);
- gfc_traverse_symtree (gfc_current_block ()->f2k_derived->sym_root,
- &set_typebound_default_access);
-
return error_flag;
}