Bug 52029 - [OOP] _copy should be PURE
Summary: [OOP] _copy should be PURE
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: fortran (show other bugs)
Version: 4.7.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: missed-optimization, rejects-valid
Depends on:
Blocks:
 
Reported: 2012-01-28 17:18 UTC by Tobias Burnus
Modified: 2012-01-31 19:01 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Tobias Burnus 2012-01-28 17:18:58 UTC
The _copy procedure should be PURE.

First, it is pure (which should help with optimization).

Secondly, it avoids an error for:

 ! Contained procedure '__copy_foo_T' of a PURE procedure must also be PURE

 elemental subroutine foo()
   type t
   end type t
   class(t), allocatable :: x
   if (allocated(x)) i = 5
 end


Draft patch:

--- class.c     (Revision 183667)
+++ class.c
@@ -717,0 +718 @@ gfc_find_derived_vtab (gfc_symbol *deriv
+                 copy->attr.pure = 1;
Comment 1 Tobias Burnus 2012-01-31 18:38:49 UTC
Author: burnus
Date: Tue Jan 31 18:38:43 2012
New Revision: 183770

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=183770
Log:
2012-01-31  Tobias Burnus  <burnus@net-b.de>

        PR fortran/52029
        * class.c (gfc_find_derived_vtab): Mark _copy function as pure.

2012-01-31  Tobias Burnus  <burnus@net-b.de>

        PR fortran/52029
        * gfortran.dg/class_49.f90: New.


Added:
    trunk/gcc/testsuite/gfortran.dg/class_49.f90
Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/class.c
    trunk/gcc/testsuite/ChangeLog
Comment 2 Tobias Burnus 2012-01-31 19:01:36 UTC
FIXED on the trunk (4.7).