[WebAssembly] Fix asan issue from https://reviews.llvm.org/D121349
[llvm-project.git] / flang / test / Semantics / resolve31.f90
blob8535ebbfa4e37947bcd2b44b57fa1de49c91cfc5
1 ! RUN: %python %S/test_errors.py %s %flang_fc1
2 ! C735 If EXTENDS appears, SEQUENCE shall not appear.
3 ! C738 The same private-or-sequence shall not appear more than once in a
4 ! given derived-type-def .
6 ! C740 If SEQUENCE appears,
7 ! the type shall have at least one component,
8 ! each data component shall be declared to be of an intrinsic type or of a sequence type,
9 ! the derived type shall not have any type parameter,
10 ! and a type-bound-procedure-part shall not appear.
11 subroutine s1
12 integer :: t0
13 !ERROR: 't0' is not a derived type
14 type(t0) :: x
15 type :: t1
16 end type
17 type, extends(t1) :: t2
18 end type
19 !ERROR: Derived type 't3' not found
20 type, extends(t3) :: t4
21 end type
22 !ERROR: 't0' is not a derived type
23 type, extends(t0) :: t5
24 end type
25 end subroutine
27 module m1
28 type t0
29 end type
30 end
31 module m2
32 type t
33 end type
34 end
35 module m3
36 type t0
37 end type
38 end
39 subroutine s2
40 use m1
41 use m2, t0 => t
42 use m3
43 !ERROR: Reference to 't0' is ambiguous
44 type, extends(t0) :: t1
45 end type
46 end subroutine
48 module m4
49 type :: t1
50 private
51 sequence
52 private ! not a fatal error
53 sequence ! not a fatal error
54 real :: t1Field
55 end type
56 type :: t1a
57 end type
58 !ERROR: A sequence type may not have the EXTENDS attribute
59 type, extends(t1a) :: t2
60 sequence
61 integer i
62 end type
63 type :: t3
64 sequence
65 integer i
66 !ERROR: A sequence type may not have a CONTAINS statement
67 contains
68 end type
69 !ERROR: A sequence type must have at least one component
70 type :: emptyType
71 sequence
72 end type emptyType
73 type :: plainType
74 real :: plainField
75 end type plainType
76 type :: sequenceType
77 sequence
78 real :: sequenceField
79 end type sequenceType
80 type :: testType
81 sequence
82 !ERROR: A sequence type data component must either be of an intrinsic type or a derived sequence type
83 class(*), allocatable :: typeStarField
84 !ERROR: A sequence type data component must either be of an intrinsic type or a derived sequence type
85 type(plainType) :: testField1
86 !Pointers are ok as an extension
87 type(plainType), pointer :: testField1p
88 type(sequenceType) :: testField2
89 procedure(real), pointer, nopass :: procField
90 end type testType
91 !ERROR: A sequence type may not have type parameters
92 type :: paramType(param)
93 integer, kind :: param
94 sequence
95 real :: paramField
96 end type paramType
97 contains
98 subroutine s3
99 type :: t1
100 !ERROR: PRIVATE is only allowed in a derived type that is in a module
101 private
102 contains
103 !ERROR: PRIVATE is only allowed in a derived type that is in a module
104 private
105 end type