Patchwork [Fortran] bessel_7.f90, CLASS in SEQUENCE, MOVE_ALLOC is pure (PR 46223, 46244, 46411)

login
register
mail settings
Submitter Tobias Burnus
Date Nov. 10, 2010, 5:12 p.m.
Message ID <4CDAD28A.6040503@net-b.de>
Download mbox | patch
Permalink /patch/70651/
State New
Headers show

Comments

Tobias Burnus - Nov. 10, 2010, 5:12 p.m.
Hi all,

the attached patches fix a couple of minor issues.

a) PR 46223: bessel_7.f90 fails on s960; I simply have bumped one 
epsilon by 1.

b) A polymorphic component (CLASS) in a BIND(C)/SEQUENCE type is not 
allowed. The patch adds diagnostic for this and fixes thus comment 7 to 
9 of PR 496244.

c) MOVE_ALLOC is a "pure subroutine". However, it was rejected as impure 
as the check only looked whether the procedure is elemental. (Elemental 
implies pure.) The check is now fixed; I also have updated documentation.

Build and regtested on x86-64-linux.
OK for the trunk?

Tobias
Steve Kargl - Nov. 10, 2010, 5:26 p.m.
On Wed, Nov 10, 2010 at 06:12:42PM +0100, Tobias Burnus wrote:
> Hi all,
> 
> the attached patches fix a couple of minor issues.
> 
> a) PR 46223: bessel_7.f90 fails on s960; I simply have bumped one 
> epsilon by 1.
> 
> b) A polymorphic component (CLASS) in a BIND(C)/SEQUENCE type is not 
> allowed. The patch adds diagnostic for this and fixes thus comment 7 to 
> 9 of PR 496244.
> 
> c) MOVE_ALLOC is a "pure subroutine". However, it was rejected as impure 
> as the check only looked whether the procedure is elemental. (Elemental 
> implies pure.) The check is now fixed; I also have updated documentation.
> 
> Build and regtested on x86-64-linux.
> OK for the trunk?
> 

OK.  For those diffs that apply to 4.5, you can also
commit to 4.5.

Patch

2010-11-10  Tobias Burnus  <burnus@net-b.de>

	PR fortran/46411
	* intrinsic.c (gfc_intrinsic_sub_interface): Check for attr.pure
	and not for attr.elemental.
	* intrinsic.texi (move_alloc): Document as being pure.

2010-11-10  Tobias Burnus  <burnus@net-b.de>

	PR fortran/46411
	* gfortran.dg/intrinsic_7.f90: New.

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)}
diff --git a/gcc/testsuite/gfortran.dg/intrinsic_7.f90 b/gcc/testsuite/gfortran.dg/intrinsic_7.f90
new file mode 100644
index 0000000..69bca66
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/intrinsic_7.f90
@@ -0,0 +1,13 @@ 
+! { dg-do compile }
+!
+! PR fortran/46411
+!
+! MOVE_ALLOC and other non-elemental but pure
+! procedures where regarded as impure.
+!
+
+pure subroutine test()
+  integer, allocatable :: a, b
+  allocate(a,b)
+  call move_alloc(a,b)
+end subroutine test