+2008-12-15 Mikael Morin <mikael.morin@tele2.fr>
+
+ 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.
+
2008-12-15 Mikael Morin <mikael.morin@tele2.fr>
PR fortran/38113
}
+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.
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. */
{
gfc_actual_arglist *actual;
gfc_constructor *c;
- gfc_ref *ref;
int n;
gcc_assert (expr1->expr_type == EXPR_VARIABLE);
/* 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;
--- /dev/null
+! { dg-do compile }
+!
+! PR fortran/38487
+! Spurious warning on pointers as elemental subroutine actual arguments
+!
+! Contributed by Harald Anlauf <anlauf@gmx.de>
+
+module gfcbug82
+ implicit none
+ type t
+ real, pointer :: q(:) =>NULL()
+ real, pointer :: r(:) =>NULL()
+ end type t
+ type (t), save :: x, y
+ real, dimension(:), pointer, save :: a => NULL(), b => NULL()
+ real, save :: c(5), d
+contains
+ elemental subroutine add (q, r)
+ real, intent (inout) :: q
+ real, intent (in) :: r
+ q = q + r
+ end subroutine add
+
+ subroutine foo ()
+ call add (y% q, x% r)
+ call add (y% q, b )
+ call add (a , x% r)
+ call add (a , b )
+ call add (y% q, d )
+ call add (a , d )
+ call add (c , x% r)
+ call add (c , b )
+ end subroutine foo
+end module gfcbug82
+
+! { dg-final { cleanup-modules "gfcbug82" } }