1! RUN: %B/test/Semantics/test_errors.sh %s %flang %t
2! Error tests for recursive use of derived types.
3
4program main
5  type :: recursive1
6    !ERROR: Recursive use of the derived type requires POINTER or ALLOCATABLE
7    type(recursive1) :: bad1
8    type(recursive1), pointer :: ok1
9    type(recursive1), allocatable :: ok2
10    !ERROR: Recursive use of the derived type requires POINTER or ALLOCATABLE
11    !ERROR: CLASS entity 'bad2' must be a dummy argument or have ALLOCATABLE or POINTER attribute
12    class(recursive1) :: bad2
13    class(recursive1), pointer :: ok3
14    class(recursive1), allocatable :: ok4
15  end type recursive1
16  type :: recursive2(kind,len)
17    integer, kind :: kind
18    integer, len :: len
19    !ERROR: Recursive use of the derived type requires POINTER or ALLOCATABLE
20    type(recursive2(kind,len)) :: bad1
21    type(recursive2(kind,len)), pointer :: ok1
22    type(recursive2(kind,len)), allocatable :: ok2
23    !ERROR: Recursive use of the derived type requires POINTER or ALLOCATABLE
24    !ERROR: CLASS entity 'bad2' must be a dummy argument or have ALLOCATABLE or POINTER attribute
25    class(recursive2(kind,len)) :: bad2
26    class(recursive2(kind,len)), pointer :: ok3
27    class(recursive2(kind,len)), allocatable :: ok4
28  end type recursive2
29  type :: recursive3(kind,len)
30    integer, kind :: kind = 1
31    integer, len :: len = 2
32    !ERROR: Recursive use of the derived type requires POINTER or ALLOCATABLE
33    type(recursive3) :: bad1
34    type(recursive3), pointer :: ok1
35    type(recursive3), allocatable :: ok2
36    !ERROR: Recursive use of the derived type requires POINTER or ALLOCATABLE
37    !ERROR: CLASS entity 'bad2' must be a dummy argument or have ALLOCATABLE or POINTER attribute
38    class(recursive3) :: bad2
39    class(recursive3), pointer :: ok3
40    class(recursive3), allocatable :: ok4
41  end type recursive3
42  !ERROR: Derived type 'recursive4' cannot extend itself
43  type, extends(recursive4) :: recursive4
44  end type recursive4
45end program main
46