49 lines · plain
1! RUN: %python %S/test_errors.py %s %flang_fc12! Error tests for recursive use of derived types.3! C744 If neither the POINTER nor the ALLOCATABLE attribute is specified, the4! declaration-type-spec in the component-def-stmt shall specify an intrinsic5! type or a previously defined derived type.6 7program main8 type :: recursive19 !ERROR: Recursive use of the derived type requires POINTER or ALLOCATABLE10 type(recursive1) :: bad111 type(recursive1), pointer :: ok112 type(recursive1), allocatable :: ok213 !ERROR: Recursive use of the derived type requires POINTER or ALLOCATABLE14 !ERROR: CLASS entity 'bad2' must be a dummy argument, allocatable, or object pointer15 class(recursive1) :: bad216 class(recursive1), pointer :: ok317 class(recursive1), allocatable :: ok418 end type recursive119 type :: recursive2(kind,len)20 integer, kind :: kind21 integer, len :: len22 !ERROR: Recursive use of the derived type requires POINTER or ALLOCATABLE23 type(recursive2(kind,len)) :: bad124 type(recursive2(kind,len)), pointer :: ok125 type(recursive2(kind,len)), allocatable :: ok226 !ERROR: Recursive use of the derived type requires POINTER or ALLOCATABLE27 !ERROR: CLASS entity 'bad2' must be a dummy argument, allocatable, or object pointer28 class(recursive2(kind,len)) :: bad229 class(recursive2(kind,len)), pointer :: ok330 class(recursive2(kind,len)), allocatable :: ok431 end type recursive232 type :: recursive3(kind,len)33 integer, kind :: kind = 134 integer, len :: len = 235 !ERROR: Recursive use of the derived type requires POINTER or ALLOCATABLE36 type(recursive3) :: bad137 type(recursive3), pointer :: ok138 type(recursive3), allocatable :: ok239 !ERROR: Recursive use of the derived type requires POINTER or ALLOCATABLE40 !ERROR: CLASS entity 'bad2' must be a dummy argument, allocatable, or object pointer41 class(recursive3) :: bad242 class(recursive3), pointer :: ok343 class(recursive3), allocatable :: ok444 end type recursive345 !ERROR: Derived type 'recursive4' cannot extend itself46 type, extends(recursive4) :: recursive447 end type recursive448end program main49