From a595913e95d59f64670364c3dea31a4774c960f3 Mon Sep 17 00:00:00 2001 From: Paul Thomas Date: Sat, 18 Aug 2007 10:47:58 +0000 Subject: [PATCH] re PR fortran/32881 (PURE attribute escapes from contained procedure) 2007-08-18 Paul Thomas PR fortran/32881 * expr.c (gfc_check_pointer_assign): If the rhs is the initialization expression for the rhs, there is no error. 2007-08-18 Paul Thomas PR fortran/32881 * gfortran.dg/pure_initializer_1.f90: New test. From-SVN: r127611 --- gcc/fortran/ChangeLog | 6 ++++++ gcc/fortran/expr.c | 3 ++- gcc/testsuite/ChangeLog | 5 +++++ .../gfortran.dg/pure_initializer_1.f90 | 17 +++++++++++++++++ 4 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gfortran.dg/pure_initializer_1.f90 diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 4103e254993..f0fa1f4e757 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,9 @@ +2007-08-18 Paul Thomas + + PR fortran/32881 + * expr.c (gfc_check_pointer_assign): If the rhs is the + initialization expression for the rhs, there is no error. + 2007-08-18 Paul Thomas PR fortran/32875 diff --git a/gcc/fortran/expr.c b/gcc/fortran/expr.c index f0de19fa48c..8c44028fb23 100644 --- a/gcc/fortran/expr.c +++ b/gcc/fortran/expr.c @@ -2749,7 +2749,8 @@ gfc_check_pointer_assign (gfc_expr *lvalue, gfc_expr *rvalue) is_pure = gfc_pure (NULL); - if (is_pure && gfc_impure_variable (lvalue->symtree->n.sym)) + if (is_pure && gfc_impure_variable (lvalue->symtree->n.sym) + && lvalue->symtree->n.sym->value != rvalue) { gfc_error ("Bad pointer object in PURE procedure at %L", &lvalue->where); return FAILURE; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 3c01d600515..992a1a03c40 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2007-08-18 Paul Thomas + + PR fortran/32881 + * gfortran.dg/pure_initializer_1.f90: New test. + 2007-08-18 Paul Thomas PR fortran/32875 diff --git a/gcc/testsuite/gfortran.dg/pure_initializer_1.f90 b/gcc/testsuite/gfortran.dg/pure_initializer_1.f90 new file mode 100644 index 00000000000..6f521a04f64 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pure_initializer_1.f90 @@ -0,0 +1,17 @@ +! { dg-do compile } +! Tests the fix for PR32881, in which the initialization +! of 'p' generated an error because the pureness of 'bar' +! escaped. +! +! Contributed by Janne Blomqvist +! +subroutine foo () + integer, pointer :: p => NULL() +contains + pure function bar (a) + integer, intent(in) :: a + integer :: bar + bar = a + end function bar +end subroutine foo + -- 2.30.2