diff options
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/fortran/ChangeLog | 8 | ||||
-rw-r--r-- | gcc/fortran/dependency.c | 34 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/gfortran.dg/elemental_dependency_2.f90 | 36 |
4 files changed, 71 insertions, 12 deletions
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 7b50b8c..e3cacc2 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,5 +1,13 @@ 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 * error.c (show_locus): Start counting columns at 0. * primary.c (match_actual_arg): Eat spaces 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; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 61a9bce..fcb0a40 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2008-12-15 Mikael Morin <mikael.morin@tele2.fr> + + PR fortran/38487 + * gfortran.dg/elemental_dependency_2.f90: New test. + 2008-12-14 Paul Thomas <pault@gcc.gnu.org> PR fortran/35937 diff --git a/gcc/testsuite/gfortran.dg/elemental_dependency_2.f90 b/gcc/testsuite/gfortran.dg/elemental_dependency_2.f90 new file mode 100644 index 0000000..2282e88 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/elemental_dependency_2.f90 @@ -0,0 +1,36 @@ +! { 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" } } |