diff mbox

[Fortran] Enable FINAL parsing support (and nothing more)

Message ID 51A3872F.1000600@net-b.de
State New
Headers show

Commit Message

Tobias Burnus May 27, 2013, 4:17 p.m. UTC
Dear all,

the attached patch now enables the *parsing* of "FINAL ::" - however, 
*no* finalization will be done. Adding FINALIZATION will be deferred to 
several follow-up patches.

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

* * *

Patches pending to be reviewed, which are also required for finalization:

a) Deallocate intent(out),allocatable polymorphic arrays, 
http://gcc.gnu.org/ml/fortran/2013-05/msg00081.html

b) Enable the generation of the finalization wrapper, 
http://gcc.gnu.org/ml/fortran/2013-05/msg00093.html

(I created the patches in the order (a) -> (b) -> this patch. However, 
each patch should be independent of another.)


I prefer to have them in the trunk to expose the (b) some real-life 
testing and to make it simpler to continue with the next step:

After the three patches have been committed, the complete finalization 
infrastructure is finally available and enabled. Minus bugs ;-), "only" 
the calls to the finalizer wrapper has to be added at various spots, 
e.g. for intent(out) (allocatable and not, honoring element+optional), 
end of scope (allocatable and not), explicit deallocate, intrinsic 
assignment (w/ and w/o realloc on assign, with 
allocatable/nonallocatable/coarray components, etc. - and all items for 
polymorphic and nonpolymorphic variables).

Tobias

Comments

Janus Weil May 28, 2013, 6:24 p.m. UTC | #1
Hi Tobias,

> the attached patch now enables the *parsing* of "FINAL ::" - however, *no*
> finalization will be done. Adding FINALIZATION will be deferred to several
> follow-up patches.
>
> Build on x86-64-gnu-linux.
> OK for the trunk?

yes, ok from my side. It's definitely time to get the finalization
ball rolling on trunk. (I'll have a look at the wrapper patch later.)

Thanks for working on this!

Cheers,
Janus
diff mbox

Patch

2013-05-27  Tobias Burnus  <burnus@net-b.de>

	PR fortran/37336
	* resolve.c (gfc_resolve_finalizers): Remove not implemented error.

2013-05-27  Tobias Burnus  <burnus@net-b.de>

	PR fortran/37336
	* gfortran.dg/finalize_11.f90: New.
	* gfortran.dg/finalize_4.f03: Remove dg-error.
	* gfortran.dg/finalize_5.f03: Ditto.
	* gfortran.dg/finalize_6.f03: Ditto.
	* gfortran.dg/finalize_7.f03: Ditto.

diff --git a/gcc/fortran/resolve.c b/gcc/fortran/resolve.c
index 78a1038..4cfc858 100644
--- a/gcc/fortran/resolve.c
+++ b/gcc/fortran/resolve.c
@@ -11241,10 +11241,6 @@  error:
 		 " defined at %L, suggest also scalar one",
 		 derived->name, &derived->declared_at);
 
-  /* TODO:  Remove this error when finalization is finished.  */
-  gfc_error ("Finalization at %L is not yet implemented",
-	     &derived->declared_at);
-
   gfc_find_derived_vtab (derived);
   return result;
 }
diff --git a/gcc/testsuite/gfortran.dg/finalize_4.f03 b/gcc/testsuite/gfortran.dg/finalize_4.f03
index 11e094f..b4c08f2 100644
--- a/gcc/testsuite/gfortran.dg/finalize_4.f03
+++ b/gcc/testsuite/gfortran.dg/finalize_4.f03
@@ -48,6 +48,3 @@  PROGRAM finalizer
   DEALLOCATE(mat)
 
 END PROGRAM finalizer
-
-! TODO: Remove this once finalization is implemented.
-! { dg-excess-errors "not yet implemented" }
diff --git a/gcc/testsuite/gfortran.dg/finalize_5.f03 b/gcc/testsuite/gfortran.dg/finalize_5.f03
index b9ec376..fb81531 100644
--- a/gcc/testsuite/gfortran.dg/finalize_5.f03
+++ b/gcc/testsuite/gfortran.dg/finalize_5.f03
@@ -107,6 +107,3 @@  PROGRAM finalizer
   IMPLICIT NONE
   ! Nothing here, errors above
 END PROGRAM finalizer
-
-! TODO: Remove this once finalization is implemented.
-! { dg-excess-errors "not yet implemented" }
diff --git a/gcc/testsuite/gfortran.dg/finalize_6.f90 b/gcc/testsuite/gfortran.dg/finalize_6.f90
index 82d662f..d155c7b 100644
--- a/gcc/testsuite/gfortran.dg/finalize_6.f90
+++ b/gcc/testsuite/gfortran.dg/finalize_6.f90
@@ -10,9 +10,9 @@  MODULE final_type
   TYPE :: mytype
     INTEGER :: fooarr(42)
     REAL :: foobar
-  CONTAINS ! { dg-error "Fortran 2003" }
-    FINAL :: finalize_single ! { dg-error "Fortran 2003" }
-  END TYPE mytype
+  CONTAINS ! { dg-error "Fortran 2003: CONTAINS block in derived type definition" }
+    FINAL :: finalize_single ! { dg-error "Fortran 2003: FINAL procedure declaration|FINAL procedure 'finalize_single' at .1. is not a SUBROUTINE" }
+  END TYPE mytype ! { dg-error "Fortran 2008: Derived type definition at .1. with empty CONTAINS section" }
 
 CONTAINS
 
@@ -28,6 +28,3 @@  PROGRAM finalizer
   IMPLICIT NONE
   ! Do nothing
 END PROGRAM finalizer
-
-! TODO: Remove this once finalization is implemented.
-! { dg-excess-errors "not yet implemented" }
diff --git a/gcc/testsuite/gfortran.dg/finalize_7.f03 b/gcc/testsuite/gfortran.dg/finalize_7.f03
index 6ca4f55..5807ed5 100644
--- a/gcc/testsuite/gfortran.dg/finalize_7.f03
+++ b/gcc/testsuite/gfortran.dg/finalize_7.f03
@@ -52,6 +52,3 @@  PROGRAM finalizer
   IMPLICIT NONE
   ! Nothing here
 END PROGRAM finalizer
-
-! TODO: Remove this once finalization is implemented.
-! { dg-excess-errors "not yet implemented" }
--- /dev/null	2013-05-27 09:23:19.299118255 +0200
+++ gcc/gcc/testsuite/gfortran.dg/finalize_11.f90	2013-05-27 11:59:29.426857773 +0200
@@ -0,0 +1,31 @@ 
+! { dg-do compile }
+! { dg-options "-std=f2003" }
+!
+! Copied from finalize_6.f90 - was before rejected as the finalization
+! wrapper uses TS29913 (-std=f2008ts) features.
+!
+
+MODULE final_type
+  IMPLICIT NONE
+
+  TYPE :: mytype
+    INTEGER :: fooarr(42)
+    REAL :: foobar
+  CONTAINS
+    FINAL :: finalize_single
+  END TYPE mytype
+
+CONTAINS
+
+  SUBROUTINE finalize_single (el)
+    IMPLICIT NONE
+    TYPE(mytype) :: el
+    ! Do nothing in this test
+  END SUBROUTINE finalize_single
+
+END MODULE final_type
+
+PROGRAM finalizer
+  IMPLICIT NONE
+  ! Do nothing
+END PROGRAM finalizer