From ea4547bbfa8ce5e1ac40c54fd9a7eb23ac1b500c Mon Sep 17 00:00:00 2001 From: Mikael Morin Date: Mon, 15 Dec 2008 19:08:42 +0100 Subject: re PR fortran/38487 (Bogus Warning: INTENT(INOUT) actual argument might interfere with actual argument) 2008-12-15 Mikael Morin PR fortran/38487 * gfortran.dg/elemental_dependency_2.f90: New test. 2008-12-15 Mikael Morin PR fortran/38487 * dependency.c (gfc_is_data_pointer): New function. (gfc_check_argument_var_dependency): Disable the warning in the pointer case. (gfc_check_dependency): Use gfc_is_data_pointer. From-SVN: r142766 --- gcc/fortran/dependency.c | 34 ++++++++++++++++++++++------------ 1 file changed, 22 insertions(+), 12 deletions(-) (limited to 'gcc/fortran/dependency.c') diff --git a/gcc/fortran/dependency.c b/gcc/fortran/dependency.c index cd768be..56a6d36 100644 --- a/gcc/fortran/dependency.c +++ b/gcc/fortran/dependency.c @@ -422,6 +422,24 @@ gfc_ref_needs_temporary_p (gfc_ref *ref) } +static int +gfc_is_data_pointer (gfc_expr *e) +{ + gfc_ref *ref; + + if (e->expr_type != EXPR_VARIABLE) + return 0; + + if (e->symtree->n.sym->attr.pointer) + return 1; + for (ref = e->ref; ref; ref = ref->next) + if (ref->type == REF_COMPONENT && ref->u.c.component->attr.pointer) + return 1; + + return 0; +} + + /* Return true if array variable VAR could be passed to the same function as argument EXPR without interfering with EXPR. INTENT is the intent of VAR. @@ -447,7 +465,9 @@ gfc_check_argument_var_dependency (gfc_expr *var, sym_intent intent, if (gfc_ref_needs_temporary_p (expr->ref) || gfc_check_dependency (var, expr, !elemental)) { - if (elemental == ELEM_DONT_CHECK_VARIABLE) + if (elemental == ELEM_DONT_CHECK_VARIABLE + && !gfc_is_data_pointer (var) + && !gfc_is_data_pointer (expr)) { /* Elemental procedures forbid unspecified intents, and we don't check dependencies for INTENT_IN args. */ @@ -664,7 +684,6 @@ gfc_check_dependency (gfc_expr *expr1, gfc_expr *expr2, bool identical) { gfc_actual_arglist *actual; gfc_constructor *c; - gfc_ref *ref; int n; gcc_assert (expr1->expr_type == EXPR_VARIABLE); @@ -700,17 +719,8 @@ gfc_check_dependency (gfc_expr *expr1, gfc_expr *expr2, bool identical) /* If either variable is a pointer, assume the worst. */ /* TODO: -fassume-no-pointer-aliasing */ - if (expr1->symtree->n.sym->attr.pointer) - return 1; - for (ref = expr1->ref; ref; ref = ref->next) - if (ref->type == REF_COMPONENT && ref->u.c.component->attr.pointer) - return 1; - - if (expr2->symtree->n.sym->attr.pointer) + if (gfc_is_data_pointer (expr1) || gfc_is_data_pointer (expr2)) return 1; - for (ref = expr2->ref; ref; ref = ref->next) - if (ref->type == REF_COMPONENT && ref->u.c.component->attr.pointer) - return 1; /* Otherwise distinct symbols have no dependencies. */ return 0; -- cgit v1.1