public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [Patch, fortran] PR32881 - PURE attribute escapes from contained  procedure
@ 2007-08-17  6:09 Paul Thomas
  2007-08-17 20:13 ` Jerry DeLisle
  0 siblings, 1 reply; 2+ messages in thread
From: Paul Thomas @ 2007-08-17  6:09 UTC (permalink / raw)
  To: Fortran List, gcc-patches

[-- Attachment #1: Type: text/plain, Size: 719 bytes --]

:ADDPATCH fortran:

This problem came about because the initialization assignment is tested 
both in the outer and the contained namespaces.  Thus, if the contained 
namespace is pure, an error was caused.  The initialization assignment 
is tested by seeing if the rhs is the same as the 'value' field of the 
lhs symbol.  The testcase is the reporter's.

Regtests on amd64/Cygwin_NT - OK for trunk?

Paul

2007-08-17  Paul Thomas  <pault@gcc.gnu.org>

    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-17  Paul Thomas  <pault@gcc.gnu.org>

    PR fortran/32881
    * gfortran.dg/pure_initializer_1.f90: New test.


 

[-- Attachment #2: pr32881.diff --]
[-- Type: text/x-patch, Size: 1461 bytes --]

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 <jb@gcc.gnu.org>
+ !
+ 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
+ 

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [Patch, fortran] PR32881 - PURE attribute escapes from contained  procedure
  2007-08-17  6:09 [Patch, fortran] PR32881 - PURE attribute escapes from contained procedure Paul Thomas
@ 2007-08-17 20:13 ` Jerry DeLisle
  0 siblings, 0 replies; 2+ messages in thread
From: Jerry DeLisle @ 2007-08-17 20:13 UTC (permalink / raw)
  To: Paul Thomas; +Cc: Fortran List, gcc-patches

Paul Thomas wrote:
> :ADDPATCH fortran:
> 
> This problem came about because the initialization assignment is tested 
> both in the outer and the contained namespaces.  Thus, if the contained 
> namespace is pure, an error was caused.  The initialization assignment 
> is tested by seeing if the rhs is the same as the 'value' field of the 
> lhs symbol.  The testcase is the reporter's.
> 
> Regtests on amd64/Cygwin_NT - OK for trunk?
> 
> Paul
Also OK,

Thanks Paul,

Jerry

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2007-08-17 20:13 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-08-17  6:09 [Patch, fortran] PR32881 - PURE attribute escapes from contained procedure Paul Thomas
2007-08-17 20:13 ` Jerry DeLisle

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).