1 ! RUN: %S/test_errors.sh %s %t %flang_fc1
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.
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
20 type :: recursive2(kind
,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
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
46 !ERROR: Derived type 'recursive4' cannot extend itself
47 type, extends(recursive4
) :: recursive4