summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gfortran.dg/finalize_8.f03
blob: 6a4a135e0da02076c38fd08fadda7157fddb52a7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
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" } }