diff options
author | Janus Weil <janus@gcc.gnu.org> | 2009-05-06 23:17:16 +0200 |
---|---|---|
committer | Janus Weil <janus@gcc.gnu.org> | 2009-05-06 23:17:16 +0200 |
commit | 713485cc676555c25f30c477f8b147bf98061c52 (patch) | |
tree | 0bf13a907194f732406ab43f087a5e03de7889c7 /gcc/fortran/primary.c | |
parent | 641cac0b195f01af249f6e96207b7b27c3094557 (diff) | |
download | gcc-713485cc676555c25f30c477f8b147bf98061c52.zip gcc-713485cc676555c25f30c477f8b147bf98061c52.tar.gz gcc-713485cc676555c25f30c477f8b147bf98061c52.tar.bz2 |
re PR fortran/39630 ([F03] Procedure Pointer Components)
2009-05-06 Janus Weil <janus@gcc.gnu.org>
Paul Thomas <pault@gcc.gnu.org>
PR fortran/39630
* decl.c (match_procedure_interface): New function to match the
interface for a PROCEDURE statement.
(match_procedure_decl): Call match_procedure_interface.
(match_ppc_decl): New function to match the declaration of a
procedure pointer component.
(gfc_match_procedure): Call match_ppc_decl.
(match_binding_attributes): Add new argument 'ppc' and handle the
POINTER attribute for procedure pointer components.
(match_procedure_in_type,gfc_match_generic): Added new argument to
match_binding_attributes.
* dump-parse-tree.c (show_expr,show_components,show_code_node): Handle
procedure pointer components.
* expr.c (free_expr0,gfc_copy_expr,gfc_simplify_expr): Handle EXPR_PPC.
(gfc_check_pointer_assign): Handle procedure pointer components, but no
full checking yet.
(is_proc_ptr_comp): New function to determine if an expression is a
procedure pointer component.
* gfortran.h (expr_t): Add EXPR_PPC.
(symbol_attribute): Add new member 'proc_pointer_comp'.
(gfc_component): Add new member 'formal'.
(gfc_exec_op): Add EXEC_CALL_PPC.
(gfc_get_default_type): Changed first argument.
(is_proc_ptr_comp): Add prototype.
(gfc_match_varspec): Add new argument.
* interface.c (compare_actual_formal): Handle procedure pointer
components.
* match.c (gfc_match_pointer_assignment,match_typebound_call): Handle
procedure pointer components.
* module.c (mio_expr): Handle EXPR_PPC.
* parse.c (parse_derived): Handle procedure pointer components.
* primary.c (gfc_match_varspec): Add new argument 'ppc_arg' and handle
procedure pointer components.
(gfc_variable_attr): Handle procedure pointer components.
(gfc_match_rvalue): Added new argument to gfc_match_varspec and changed
first argument of gfc_get_default_type.
(match_variable): Added new argument to gfc_match_varspec.
* resolve.c (resolve_entries,set_type,resolve_fl_parameter): Changed
first argument of gfc_get_default_type.
(resolve_structure_cons,resolve_actual_arglist): Handle procedure
pointer components.
(resolve_ppc_call): New function to resolve a call to a procedure
pointer component (subroutine).
(resolve_expr_ppc): New function to resolve a call to a procedure
pointer component (function).
(gfc_resolve_expr): Handle EXPR_PPC.
(resolve_code): Handle EXEC_CALL_PPC.
(resolve_fl_derived): Copy the interface for a procedure pointer
component.
(resolve_symbol): Fix overlong line.
* st.c (gfc_free_statement): Handle EXEC_CALL_PPC.
* symbol.c (gfc_get_default_type): Changed first argument.
(gfc_set_default_type): Changed first argument of gfc_get_default_type.
(gfc_add_component): Initialize ts.type to BT_UNKNOWN.
* trans.h (gfc_conv_function_call): Renamed.
* trans.c (gfc_trans_code): Handle EXEC_CALL_PPC.
* trans-expr.c (gfc_conv_component_ref): Ditto.
(gfc_conv_function_val): Rename to 'conv_function_val', add new
argument 'expr' and handle procedure pointer components.
(gfc_conv_operator_assign): Renamed gfc_conv_function_val.
(gfc_apply_interface_mapping_to_expr): Handle EXPR_PPC.
(gfc_conv_function_call): Rename to 'gfc_conv_procedure_call', add new
argument 'expr' and handle procedure pointer components.
(gfc_get_proc_ptr_comp): New function to get the backend decl for a
procedure pointer component.
(gfc_conv_function_expr): Renamed gfc_conv_function_call.
(gfc_conv_structure): Handle procedure pointer components.
* trans-intrinsic.c (gfc_conv_intrinsic_funcall,
conv_generic_with_optional_char_arg): Renamed gfc_conv_function_call.
* trans-stmt.h (gfc_get_proc_ptr_comp): Add prototype.
* trans-stmt.c (gfc_trans_call): Renamed gfc_conv_function_call.
* trans-types.h (gfc_get_ppc_type): Add prototype.
* trans-types.c (gfc_get_ppc_type): New function to build a tree node
for a procedure pointer component.
(gfc_get_derived_type): Handle procedure pointer components.
2009-05-06 Janus Weil <janus@gcc.gnu.org>
PR fortran/39630
* gfortran.dg/proc_decl_1.f90: Modified.
* gfortran.dg/proc_ptr_comp_1.f90: New.
* gfortran.dg/proc_ptr_comp_2.f90: New.
* gfortran.dg/proc_ptr_comp_3.f90: New.
* gfortran.dg/proc_ptr_comp_4.f90: New.
* gfortran.dg/proc_ptr_comp_5.f90: New.
* gfortran.dg/proc_ptr_comp_6.f90: New.
Co-Authored-By: Paul Thomas <pault@gcc.gnu.org>
From-SVN: r147206
Diffstat (limited to 'gcc/fortran/primary.c')
-rw-r--r-- | gcc/fortran/primary.c | 51 |
1 files changed, 34 insertions, 17 deletions
diff --git a/gcc/fortran/primary.c b/gcc/fortran/primary.c index 7e41535..96fbddc 100644 --- a/gcc/fortran/primary.c +++ b/gcc/fortran/primary.c @@ -1708,10 +1708,13 @@ extend_ref (gfc_expr *primary, gfc_ref *tail) variable like member references or substrings. If equiv_flag is set we only match stuff that is allowed inside an EQUIVALENCE statement. sub_flag tells whether we expect a type-bound procedure found - to be a subroutine as part of CALL or a FUNCTION. */ + to be a subroutine as part of CALL or a FUNCTION. For procedure pointer + components, 'ppc_arg' determines whether the PPC may be called (with an + argument list), or whether it may just be referred to as a pointer. */ match -gfc_match_varspec (gfc_expr *primary, int equiv_flag, bool sub_flag) +gfc_match_varspec (gfc_expr *primary, int equiv_flag, bool sub_flag, + bool ppc_arg) { char name[GFC_MAX_SYMBOL_LEN + 1]; gfc_ref *substring, *tail; @@ -1754,7 +1757,7 @@ gfc_match_varspec (gfc_expr *primary, int equiv_flag, bool sub_flag) return MATCH_YES; if (sym->ts.type == BT_UNKNOWN && gfc_peek_ascii_char () == '%' - && gfc_get_default_type (sym, sym->ns)->type == BT_DERIVED) + && gfc_get_default_type (sym->name, sym->ns)->type == BT_DERIVED) gfc_set_default_type (sym, 0, sym->ns); if (sym->ts.type != BT_DERIVED || gfc_match_char ('%') != MATCH_YES) @@ -1826,6 +1829,20 @@ gfc_match_varspec (gfc_expr *primary, int equiv_flag, bool sub_flag) primary->ts = component->ts; + if (component->attr.proc_pointer && ppc_arg + && !gfc_matching_procptr_assignment) + { + primary->expr_type = EXPR_PPC; + m = gfc_match_actual_arglist (component->attr.subroutine, + &primary->value.compcall.actual); + if (m == MATCH_ERROR) + return MATCH_ERROR; + if (m == MATCH_NO) + primary->value.compcall.actual = NULL; + + break; + } + if (component->as != NULL) { tail = extend_ref (primary, tail); @@ -1847,7 +1864,7 @@ check_substring: unknown = false; if (primary->ts.type == BT_UNKNOWN) { - if (gfc_get_default_type (sym, sym->ns)->type == BT_CHARACTER) + if (gfc_get_default_type (sym->name, sym->ns)->type == BT_CHARACTER) { gfc_set_default_type (sym, 0, sym->ns); primary->ts = sym->ts; @@ -1925,7 +1942,7 @@ gfc_variable_attr (gfc_expr *expr, gfc_typespec *ts) allocatable = attr.allocatable; target = attr.target; - if (pointer) + if (pointer || attr.proc_pointer) target = 1; if (ts != NULL && expr->ts.type == BT_UNKNOWN) @@ -1971,7 +1988,7 @@ gfc_variable_attr (gfc_expr *expr, gfc_typespec *ts) pointer = ref->u.c.component->attr.pointer; allocatable = ref->u.c.component->attr.allocatable; - if (pointer) + if (pointer || attr.proc_pointer) target = 1; break; @@ -2478,7 +2495,7 @@ gfc_match_rvalue (gfc_expr **result) e->expr_type = EXPR_VARIABLE; e->symtree = symtree; - m = gfc_match_varspec (e, 0, false); + m = gfc_match_varspec (e, 0, false, true); break; case FL_PARAMETER: @@ -2495,7 +2512,7 @@ gfc_match_rvalue (gfc_expr **result) } e->symtree = symtree; - m = gfc_match_varspec (e, 0, false); + m = gfc_match_varspec (e, 0, false, true); if (sym->ts.is_c_interop || sym->ts.is_iso_c) break; @@ -2551,7 +2568,7 @@ gfc_match_rvalue (gfc_expr **result) e = gfc_get_expr (); e->expr_type = EXPR_VARIABLE; e->symtree = symtree; - m = gfc_match_varspec (e, 0, false); + m = gfc_match_varspec (e, 0, false, true); break; } @@ -2578,7 +2595,7 @@ gfc_match_rvalue (gfc_expr **result) e->symtree = symtree; e->expr_type = EXPR_VARIABLE; - m = gfc_match_varspec (e, 0, false); + m = gfc_match_varspec (e, 0, false, true); break; } @@ -2658,7 +2675,7 @@ gfc_match_rvalue (gfc_expr **result) if (gfc_peek_ascii_char () == '%' && sym->ts.type == BT_UNKNOWN - && gfc_get_default_type (sym, sym->ns)->type == BT_DERIVED) + && gfc_get_default_type (sym->name, sym->ns)->type == BT_DERIVED) gfc_set_default_type (sym, 0, sym->ns); /* If the symbol has a dimension attribute, the expression is a @@ -2676,7 +2693,7 @@ gfc_match_rvalue (gfc_expr **result) e = gfc_get_expr (); e->symtree = symtree; e->expr_type = EXPR_VARIABLE; - m = gfc_match_varspec (e, 0, false); + m = gfc_match_varspec (e, 0, false, true); break; } @@ -2701,7 +2718,7 @@ gfc_match_rvalue (gfc_expr **result) /*FIXME:??? gfc_match_varspec does set this for us: */ e->ts = sym->ts; - m = gfc_match_varspec (e, 0, false); + m = gfc_match_varspec (e, 0, false, true); break; } @@ -2725,7 +2742,7 @@ gfc_match_rvalue (gfc_expr **result) implicit_char = false; if (sym->ts.type == BT_UNKNOWN) { - ts = gfc_get_default_type (sym,NULL); + ts = gfc_get_default_type (sym->name, NULL); if (ts->type == BT_CHARACTER) implicit_char = true; } @@ -2790,7 +2807,7 @@ gfc_match_rvalue (gfc_expr **result) /* If our new function returns a character, array or structure type, it might have subsequent references. */ - m = gfc_match_varspec (e, 0, false); + m = gfc_match_varspec (e, 0, false, true); if (m == MATCH_NO) m = MATCH_YES; @@ -2963,7 +2980,7 @@ match_variable (gfc_expr **result, int equiv_flag, int host_flag) if (gfc_peek_ascii_char () == '%' && sym->ts.type == BT_UNKNOWN - && gfc_get_default_type (sym, implicit_ns)->type == BT_DERIVED) + && gfc_get_default_type (sym->name, implicit_ns)->type == BT_DERIVED) gfc_set_default_type (sym, 0, implicit_ns); } @@ -2975,7 +2992,7 @@ match_variable (gfc_expr **result, int equiv_flag, int host_flag) expr->where = where; /* Now see if we have to do more. */ - m = gfc_match_varspec (expr, equiv_flag, false); + m = gfc_match_varspec (expr, equiv_flag, false, false); if (m != MATCH_YES) { gfc_free_expr (expr); |