[flang] Accept polymorphic component element in storage_size
[llvm-project.git] / flang / test / Semantics / resolve42.f90
blob5a433d06ccc1dfd64ad46d554fb216ccb8c77693
1 ! RUN: %python %S/test_errors.py %s %flang_fc1
2 subroutine s1
3 !ERROR: Array 'x' without ALLOCATABLE or POINTER attribute must have explicit shape
4 common x(:), y(4), z
5 end
7 subroutine s2
8 common /c1/ x, y, z
9 !ERROR: 'y' is already in a COMMON block
10 common y
11 end
13 subroutine s3
14 !ERROR: 'x' may not be a procedure as it is in a COMMON block
15 procedure(real) :: x
16 common x
17 common y
18 !ERROR: 'y' may not be a procedure as it is in a COMMON block
19 procedure(real) :: y
20 end
22 subroutine s5
23 integer x(2)
24 !ERROR: The dimensions of 'x' have already been declared
25 common x(4), y(4)
26 !ERROR: The dimensions of 'y' have already been declared
27 real y(2)
28 end
30 function f6(x) result(r)
31 !ERROR: ALLOCATABLE object 'y' may not appear in a COMMON block
32 !ERROR: Dummy argument 'x' may not appear in a COMMON block
33 common y,x,z
34 allocatable y
35 !ERROR: Function result 'r' may not appear in a COMMON block
36 common r
37 end
39 module m7
40 !ERROR: Variable 'w' with BIND attribute may not appear in a COMMON block
41 !ERROR: Variable 'z' with BIND attribute may not appear in a COMMON block
42 common w,z
43 integer, bind(c) :: z
44 integer, bind(c,name="w") :: w
45 end
47 module m8
48 type t
49 end type
50 class(*), pointer :: x
51 !ERROR: Unlimited polymorphic pointer 'x' may not appear in a COMMON block
52 !ERROR: Unlimited polymorphic pointer 'y' may not appear in a COMMON block
53 common x, y
54 class(*), pointer :: y
55 end
57 module m9
58 integer x
59 end
60 subroutine s9
61 use m9
62 !ERROR: 'x' is use-associated from module 'm9' and cannot be re-declared
63 common x
64 end
66 module m10
67 type t
68 end type
69 type(t) :: x
70 !ERROR: Derived type 'x' in COMMON block must have the BIND or SEQUENCE attribute
71 common x
72 end
74 module m11
75 type t1
76 sequence
77 integer, allocatable :: a
78 end type
79 type t2
80 sequence
81 type(t1) :: b
82 integer:: c
83 end type
84 type(t2) :: x2
85 !ERROR: Derived type variable 'x2' may not appear in a COMMON block due to ALLOCATABLE component
86 common /c2/ x2
87 end
89 module m12
90 type t1
91 sequence
92 integer :: a = 123
93 end type
94 type t2
95 sequence
96 type(t1) :: b
97 integer:: c
98 end type
99 type(t2) :: x2
100 !ERROR: Derived type variable 'x2' may not appear in a COMMON block due to component with default initialization
101 common /c3/ x2
104 subroutine s13
105 block
106 !ERROR: COMMON statement is not allowed in a BLOCK construct
107 common x
108 end block
111 subroutine s14
112 !ERROR: 'c' appears as a COMMON block in a BIND statement but not in a COMMON statement
113 bind(c) :: /c/