Index: gcc/fortran/expr.c =================================================================== *** gcc/fortran/expr.c (revision 127505) --- gcc/fortran/expr.c (working copy) *************** gfc_check_pointer_assign (gfc_expr *lval *** 2749,2755 **** is_pure = gfc_pure (NULL); ! if (is_pure && gfc_impure_variable (lvalue->symtree->n.sym)) { gfc_error ("Bad pointer object in PURE procedure at %L", &lvalue->where); return FAILURE; --- 2749,2756 ---- is_pure = gfc_pure (NULL); ! 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; Index: gcc/testsuite/gfortran.dg/pure_initializer_1.f90 =================================================================== *** gcc/testsuite/gfortran.dg/pure_initializer_1.f90 (revision 0) --- gcc/testsuite/gfortran.dg/pure_initializer_1.f90 (revision 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 +