http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46411
Summary: MOVE_ALLOC wrongly rejected as impure Product: gcc Version: 4.6.0 Status: UNCONFIRMED Keywords: rejects-valid Severity: normal Priority: P3 Component: fortran AssignedTo: unassig...@gcc.gnu.org ReportedBy: bur...@gcc.gnu.org Reported in #gfortran's IRC channel. MOVE_ALLOC is pure but rejected in PURE programs: "13.7.118 MOVE_ALLOC (FROM, TO)" "Class. Pure subroutine." call move_alloc(a,b) 1 Error: Subroutine call to 'move_alloc' at (1) is not PURE pure subroutine test() integer, allocatable :: a, b allocate(a,b) call move_alloc(a,b) end subroutine test Untested patch. Actually, I am not sure that CLASS_INQUIRY and CLASS_TRANSFORMATIONAL functions are PURE. Currently, all functions which are not IMPURE are marked as PURE. diff --git a/gcc/fortran/intrinsic.c b/gcc/fortran/intrinsic.c index f7f0e05..d17544c 100644 --- a/gcc/fortran/intrinsic.c +++ b/gcc/fortran/intrinsic.c @@ -4193,7 +4193,7 @@ gfc_intrinsic_sub_interface (gfc_code *c, int error_flag) c->resolved_sym->attr.elemental = isym->elemental; } - if (gfc_pure (NULL) && !isym->elemental) + if (gfc_pure (NULL) && !isym->pure) { gfc_error ("Subroutine call to intrinsic '%s' at %L is not PURE", name, &c->loc); diff --git a/gcc/fortran/intrinsic.texi b/gcc/fortran/intrinsic.texi index 09f5278..3b81c2d 100644 --- a/gcc/fortran/intrinsic.texi +++ b/gcc/fortran/intrinsic.texi @@ -8977,7 +8977,7 @@ end program Fortran 2003 and later @item @emph{Class}: -Subroutine +Pure subroutine @item @emph{Syntax}: @code{CALL MOVE_ALLOC(FROM, TO)}