This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


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
2010-11-10  Tobias Burnus  <burnus@net-b.de>

	PR fortran/46223
	* gfortran.dg/bessel_7.f90: Bump allowed precision to avoid
	failure on s390.

diff --git a/gcc/testsuite/gfortran.dg/bessel_7.f90 b/gcc/testsuite/gfortran.dg/bessel_7.f90
index 0620448..8c4f0d9 100644
--- a/gcc/testsuite/gfortran.dg/bessel_7.f90
+++ b/gcc/testsuite/gfortran.dg/bessel_7.f90
@@ -12,7 +12,7 @@
 implicit none
 real,parameter :: values(*) = [0.0, 0.5, 1.0, 0.9, 1.8,2.0,3.0,4.0,4.25,8.0,34.53, 475.78] 
 real,parameter :: myeps(size(values)) = epsilon(0.0) &
-                  * [2, 3, 4, 5, 8, 2, 12, 6, 7, 6, 30, 168 ]
+                  * [2, 3, 4, 5, 8, 2, 12, 6, 7, 6, 31, 168 ]
 ! The following is sufficient for me - the values above are a bit
 ! more tolerant
 !                  * [0, 0, 0, 3, 3, 0, 9, 0, 2, 1, 22, 130 ]
2010-11-10  Tobias Burnus <burnus@net-b.de>

	PR fortran/46244
	* resolve.c (resolve_fl_derived): Don't allow CLASS in
	sequence/BIND(C) types.

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

	PR fortran/46244
	* gfortran.dg/class_30.f90: New.

diff --git a/gcc/fortran/resolve.c b/gcc/fortran/resolve.c
index f18d28c..2c9d6f6 100644
--- a/gcc/fortran/resolve.c
+++ b/gcc/fortran/resolve.c
@@ -11491,6 +11491,13 @@ resolve_fl_derived (gfc_symbol *sym)
 			     sym->name, &sym->declared_at) == FAILURE)
 	return FAILURE;
 
+      if ((sym->attr.sequence || sym->attr.is_bind_c) && c->ts.type == BT_CLASS)
+	{
+	  gfc_error ("Polymorphic component %s at %L in SEQUENCE or BIND(C) "
+		     "type %s", c->name, &c->loc, sym->name);
+	  return FAILURE;
+	}
+
       if (sym->attr.sequence)
 	{
 	  if (c->ts.type == BT_DERIVED && c->ts.u.derived->attr.sequence == 0)
diff --git a/gcc/testsuite/gfortran.dg/class_30.f90 b/gcc/testsuite/gfortran.dg/class_30.f90
new file mode 100644
index 0000000..a998110
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/class_30.f90
@@ -0,0 +1,19 @@
+! { dg-do compile }
+!
+! PR fortran/46244 (comments 7 to 9)
+!
+! gfortran accepted CLASS in bind(C) and SEQUENCE types
+!
+type :: t
+  integer :: i
+end type t
+
+type t2
+  sequence
+  class(t), pointer :: x ! { dg-error "Polymorphic component x at .1. in SEQUENCE or BIND" }
+end type t2
+
+type, bind(C):: t3
+  class(t), pointer :: y ! { dg-error "may not be C interoperable|Polymorphic component y at .1. in SEQUENCE or BIND" }
+end type t3
+end
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

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]