summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gfortran.dg/finalize_8.f03
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/testsuite/gfortran.dg/finalize_8.f03')
-rw-r--r--gcc/testsuite/gfortran.dg/finalize_8.f0337
1 files changed, 37 insertions, 0 deletions
diff --git a/gcc/testsuite/gfortran.dg/finalize_8.f03 b/gcc/testsuite/gfortran.dg/finalize_8.f03
new file mode 100644
index 000000000..6a4a135e0
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/finalize_8.f03
@@ -0,0 +1,37 @@
+! { dg-do compile }
+
+! Parsing of finalizer procedure definitions.
+! Check that FINAL-declarations are only allowed on types defined in the
+! specification part of a module.
+
+MODULE final_type
+ IMPLICIT NONE
+
+CONTAINS
+
+ SUBROUTINE bar
+ IMPLICIT NONE
+
+ TYPE :: mytype
+ INTEGER, ALLOCATABLE :: fooarr(:)
+ REAL :: foobar
+ CONTAINS
+ FINAL :: myfinal ! { dg-error "in the specification part of a MODULE" }
+ END TYPE mytype
+
+ CONTAINS
+
+ SUBROUTINE myfinal (el)
+ TYPE(mytype) :: el
+ END SUBROUTINE myfinal
+
+ END SUBROUTINE bar
+
+END MODULE final_type
+
+PROGRAM finalizer
+ IMPLICIT NONE
+ ! Do nothing here
+END PROGRAM finalizer
+
+! { dg-final { cleanup-modules "final_type" } }