1! RUN: %python %S/test_errors.py %s %flang_fc1 2! Error tests for recursive use of derived types. 3! C744 If neither the POINTER nor the ALLOCATABLE attribute is specified, the 4! declaration-type-spec in the component-def-stmt shall specify an intrinsic 5! type or a previously defined derived type. 6 7program main 8 type :: recursive1 9 !ERROR: Recursive use of the derived type requires POINTER or ALLOCATABLE 10 type(recursive1) :: bad1 11 type(recursive1), pointer :: ok1 12 type(recursive1), allocatable :: ok2 13 !ERROR: Recursive use of the derived type requires POINTER or ALLOCATABLE 14 !ERROR: CLASS entity 'bad2' must be a dummy argument, allocatable, or object pointer 15 class(recursive1) :: bad2 16 class(recursive1), pointer :: ok3 17 class(recursive1), allocatable :: ok4 18 end type recursive1 19 type :: recursive2(kind,len) 20 integer, kind :: kind 21 integer, len :: len 22 !ERROR: Recursive use of the derived type requires POINTER or ALLOCATABLE 23 type(recursive2(kind,len)) :: bad1 24 type(recursive2(kind,len)), pointer :: ok1 25 type(recursive2(kind,len)), allocatable :: ok2 26 !ERROR: Recursive use of the derived type requires POINTER or ALLOCATABLE 27 !ERROR: CLASS entity 'bad2' must be a dummy argument, allocatable, or object pointer 28 class(recursive2(kind,len)) :: bad2 29 class(recursive2(kind,len)), pointer :: ok3 30 class(recursive2(kind,len)), allocatable :: ok4 31 end type recursive2 32 type :: recursive3(kind,len) 33 integer, kind :: kind = 1 34 integer, len :: len = 2 35 !ERROR: Recursive use of the derived type requires POINTER or ALLOCATABLE 36 type(recursive3) :: bad1 37 type(recursive3), pointer :: ok1 38 type(recursive3), allocatable :: ok2 39 !ERROR: Recursive use of the derived type requires POINTER or ALLOCATABLE 40 !ERROR: CLASS entity 'bad2' must be a dummy argument, allocatable, or object pointer 41 class(recursive3) :: bad2 42 class(recursive3), pointer :: ok3 43 class(recursive3), allocatable :: ok4 44 end type recursive3 45 !ERROR: Derived type 'recursive4' cannot extend itself 46 type, extends(recursive4) :: recursive4 47 end type recursive4 48end program main 49