Break circular dependency between FIR dialect and utilities
[llvm-project.git] / flang / test / Semantics / bad-forward-type.f90
blob19e23e654642fdb7f5e79ce19ea84d0088265fc7
1 ! RUN: %python %S/test_errors.py %s %flang_fc1
2 ! Forward references to derived types (error cases)
3 ! C732 A parent-type-name shall be the name of a previously defined
4 ! extensible type (7.5.7).
6 !ERROR: The derived type 'undef' was forward-referenced but not defined
7 type(undef) function f1()
8 call sub1(f1)
9 end function
11 !ERROR: The derived type 'undef' was forward-referenced but not defined
12 type(undef) function f2() result(r)
13 call sub2(r)
14 end function
16 !ERROR: The derived type 'undefpdt' was forward-referenced but not defined
17 type(undefpdt(1)) function f3()
18 call sub3(f3)
19 end function
21 !ERROR: The derived type 'undefpdt' was forward-referenced but not defined
22 type(undefpdt(1)) function f4() result(r)
23 call sub4(f4)
24 end function
26 !ERROR: 'bad' is not the name of a parameter for derived type 'pdt'
27 type(pdt(bad=1)) function f5()
28 type :: pdt(good)
29 integer, kind :: good = kind(0)
30 integer(kind=good) :: n
31 end type
32 end function
34 subroutine s1(q1)
35 !ERROR: The derived type 'undef' was forward-referenced but not defined
36 implicit type(undef)(q)
37 end subroutine
39 subroutine s2(q1)
40 !ERROR: The derived type 'undefpdt' was forward-referenced but not defined
41 implicit type(undefpdt(1))(q)
42 end subroutine
44 subroutine s3
45 type :: t1
46 !ERROR: Derived type 'undef' not found
47 type(undef) :: x
48 end type
49 end subroutine
51 subroutine s4
52 type :: t1
53 !ERROR: Derived type 'undefpdt' not found
54 type(undefpdt(1)) :: x
55 end type
56 end subroutine
58 subroutine s5(x)
59 !ERROR: Derived type 'undef' not found
60 type(undef) :: x
61 end subroutine
63 subroutine s6(x)
64 !ERROR: Derived type 'undefpdt' not found
65 type(undefpdt(1)) :: x
66 end subroutine
68 subroutine s7(x)
69 !ERROR: Derived type 'undef' not found
70 type, extends(undef) :: t
71 end type
72 end subroutine
74 subroutine s8
75 implicit type(t2)(x)
76 !ERROR: Cannot construct value for derived type 't2' before it is defined
77 parameter(y=t2(12.3))
78 type t2
79 real :: c
80 end type
81 end subroutine
83 subroutine s9
84 type con
85 Type(t(3)), pointer :: y
86 end type
87 !ERROR: Cannot construct value for derived type 't' before it is defined
88 Integer :: nn = Size(Transfer(t(3)(666),[0]))
89 type :: t(n)
90 integer, kind :: n = 3
91 end type
92 end subroutine s9
94 subroutine s10
95 type t
96 !ERROR: The derived type 'undef' has not been defined
97 type(undef), pointer :: y
98 end type
99 end subroutine s10