diff options
author | Daniel Kraft <d@domob.eu> | 2008-08-31 12:00:30 +0200 |
---|---|---|
committer | Daniel Kraft <domob@gcc.gnu.org> | 2008-08-31 12:00:30 +0200 |
commit | e157f73660e50bd02f5c2c6d94624de70303e579 (patch) | |
tree | f1e34fc56018b9fd2a92bf9de5854b3ef33fc9bb /gcc/fortran/module.c | |
parent | f40751dd3417bc2b10d85a8f6afa3771c6de7101 (diff) | |
download | gcc-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/module.c')
-rw-r--r-- | gcc/fortran/module.c | 44 |
1 files changed, 43 insertions, 1 deletions
diff --git a/gcc/fortran/module.c b/gcc/fortran/module.c index 0f504ef..c927803 100644 --- a/gcc/fortran/module.c +++ b/gcc/fortran/module.c @@ -1698,6 +1698,12 @@ static const mstring binding_overriding[] = minit ("NON_OVERRIDABLE", 1), minit (NULL, -1) }; +static const mstring binding_generic[] = +{ + minit ("SPECIFIC", 0), + minit ("GENERIC", 1), + minit (NULL, -1) +}; /* Specialization of mio_name. */ @@ -3189,6 +3195,8 @@ mio_namespace_ref (gfc_namespace **nsp) /* Save/restore the f2k_derived namespace of a derived-type symbol. */ +static gfc_namespace* current_f2k_derived; + static void mio_typebound_proc (gfc_typebound_proc** proc) { @@ -3202,13 +3210,13 @@ mio_typebound_proc (gfc_typebound_proc** proc) gcc_assert (*proc); mio_lparen (); - mio_symtree_ref (&(*proc)->target); (*proc)->access = MIO_NAME (gfc_access) ((*proc)->access, access_types); (*proc)->nopass = mio_name ((*proc)->nopass, binding_passing); (*proc)->non_overridable = mio_name ((*proc)->non_overridable, binding_overriding); + (*proc)->is_generic = mio_name ((*proc)->is_generic, binding_generic); if (iomode == IO_INPUT) (*proc)->pass_arg = NULL; @@ -3217,6 +3225,38 @@ mio_typebound_proc (gfc_typebound_proc** proc) mio_integer (&flag); (*proc)->pass_arg_num = (unsigned) flag; + if ((*proc)->is_generic) + { + gfc_tbp_generic* g; + + mio_lparen (); + + if (iomode == IO_OUTPUT) + for (g = (*proc)->u.generic; g; g = g->next) + mio_allocated_string (g->specific_st->name); + else + { + (*proc)->u.generic = NULL; + while (peek_atom () != ATOM_RPAREN) + { + g = gfc_get_tbp_generic (); + g->specific = NULL; + + require_atom (ATOM_STRING); + gfc_get_sym_tree (atom_string, current_f2k_derived, + &g->specific_st); + gfc_free (atom_string); + + g->next = (*proc)->u.generic; + (*proc)->u.generic = g; + } + } + + mio_rparen (); + } + else + mio_symtree_ref (&(*proc)->u.specific); + mio_rparen (); } @@ -3260,6 +3300,8 @@ mio_finalizer (gfc_finalizer **f) static void mio_f2k_derived (gfc_namespace *f2k) { + current_f2k_derived = f2k; + /* Handle the list of finalizer procedures. */ mio_lparen (); if (iomode == IO_OUTPUT) |