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