diff options
author | Janus Weil <janus@gcc.gnu.org> | 2009-05-18 11:19:20 +0200 |
---|---|---|
committer | Janus Weil <janus@gcc.gnu.org> | 2009-05-18 11:19:20 +0200 |
commit | 23e38561c5027f1c94174df94996837a11cb7c51 (patch) | |
tree | d8f5a5199d69060ee64ad6792b13388fc7249fdf /gcc/fortran/interface.c | |
parent | 75df395f15f2641bfcae7f1179d3ef963771379c (diff) | |
download | gcc-23e38561c5027f1c94174df94996837a11cb7c51.zip gcc-23e38561c5027f1c94174df94996837a11cb7c51.tar.gz gcc-23e38561c5027f1c94174df94996837a11cb7c51.tar.bz2 |
re PR fortran/36947 (Attributes not fully checked comparing actual vs dummy procedure)
2009-05-18 Janus Weil <janus@gcc.gnu.org>
PR fortran/36947
PR fortran/40039
* expr.c (gfc_check_pointer_assign): Check intents when comparing
interfaces.
* gfortran.h (typedef struct gfc_intrinsic_arg): Add 'intent' member.
(gfc_compare_interfaces): Additional argument.
* interface.c (operator_correspondence): Add check for equality of
intents, and new argument 'intent_check'.
(gfc_compare_interfaces): New argument 'intent_check', which is passed
on to operator_correspondence.
(check_interface1): Don't check intents when comparing interfaces.
(compare_parameter): Do check intents when comparing interfaces.
* intrinsic.c (add_sym): Add intents for arguments of intrinsic
procedures.
(add_sym_1,add_sym_1s,add_sym_1m,add_sym_2,add_sym_2s,add_sym_3,
add_sym_3ml,add_sym_3red,add_sym_3s,add_sym_4): Use INTENT_IN by
default.
(add_sym_1_intent,add_sym_1s_intent,add_sym_2s_intent,add_sym_3s_intent)
: New functions to add intrinsic symbols, specifying custom intents.
(add_sym_4s,add_sym_5s): Add new arguments to specify intents.
(add_functions,add_subroutines): Add intents for various intrinsics.
* resolve.c (check_generic_tbp_ambiguity): Don't check intents when
comparing interfaces.
* symbol.c (gfc_copy_formal_args_intr): Copy intent.
2009-05-18 Janus Weil <janus@gcc.gnu.org>
PR fortran/36947
PR fortran/40039
* gfortran.dg/interface_27.f90: New.
* gfortran.dg/interface_28.f90: New.
* gfortran.dg/proc_ptr_11.f90: Fixing invalid test case.
* gfortran.dg/proc_ptr_result_1.f90: Ditto.
From-SVN: r147655
Diffstat (limited to 'gcc/fortran/interface.c')
-rw-r--r-- | gcc/fortran/interface.c | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/gcc/fortran/interface.c b/gcc/fortran/interface.c index f2d1465..48c026c 100644 --- a/gcc/fortran/interface.c +++ b/gcc/fortran/interface.c @@ -873,23 +873,32 @@ count_types_test (gfc_formal_arglist *f1, gfc_formal_arglist *f2) which makes this test much easier than that for generic tests. This subroutine is also used when comparing a formal and actual - argument list when an actual parameter is a dummy procedure. At - that point, two formal interfaces must be compared for equality - which is what happens here. */ + argument list when an actual parameter is a dummy procedure, and in + procedure pointer assignments. In these cases, two formal interfaces must be + compared for equality which is what happens here. 'intent_flag' specifies + whether the intents of the arguments are required to match, which is not the + case for ambiguity checks. */ static int -operator_correspondence (gfc_formal_arglist *f1, gfc_formal_arglist *f2) +operator_correspondence (gfc_formal_arglist *f1, gfc_formal_arglist *f2, + int intent_flag) { for (;;) { + /* Check existence. */ if (f1 == NULL && f2 == NULL) break; if (f1 == NULL || f2 == NULL) return 1; + /* Check type and rank. */ if (!compare_type_rank (f1->sym, f2->sym)) return 1; + /* Check intent. */ + if (intent_flag && (f1->sym->attr.intent != f2->sym->attr.intent)) + return 1; + f1 = f1->next; f2 = f2->next; } @@ -961,7 +970,8 @@ generic_correspondence (gfc_formal_arglist *f1, gfc_formal_arglist *f2) would be ambiguous between the two interfaces, zero otherwise. */ int -gfc_compare_interfaces (gfc_symbol *s1, gfc_symbol *s2, int generic_flag) +gfc_compare_interfaces (gfc_symbol *s1, gfc_symbol *s2, int generic_flag, + int intent_flag) { gfc_formal_arglist *f1, *f2; @@ -1001,7 +1011,7 @@ gfc_compare_interfaces (gfc_symbol *s1, gfc_symbol *s2, int generic_flag) } else { - if (operator_correspondence (f1, f2)) + if (operator_correspondence (f1, f2, intent_flag)) return 0; } @@ -1080,7 +1090,7 @@ check_interface1 (gfc_interface *p, gfc_interface *q0, if (p->sym->name == q->sym->name && p->sym->module == q->sym->module) continue; - if (gfc_compare_interfaces (p->sym, q->sym, generic_flag)) + if (gfc_compare_interfaces (p->sym, q->sym, generic_flag, 0)) { if (referenced) { @@ -1362,7 +1372,7 @@ compare_parameter (gfc_symbol *formal, gfc_expr *actual, || actual->symtree->n.sym->attr.external) return 1; /* Assume match. */ - if (!gfc_compare_interfaces (formal, actual->symtree->n.sym, 0)) + if (!gfc_compare_interfaces (formal, actual->symtree->n.sym, 0, 1)) goto proc_fail; return 1; |