allocate06.f90
5.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
! RUN: %S/test_errors.sh %s %t %f18
! Check for semantic errors in ALLOCATE statements
subroutine C935(l, ac1, ac2, ac3, dc1, dc2, ec1, ec2, aa, ab, ab2, ea, eb, da, db, whatever, something, something_else)
! A type-param-value in a type-spec shall be an asterisk if and only if each
! allocate-object is a dummy argument for which the corresponding type parameter
! is assumed.
type A(la)
integer, len :: la
integer vector(la)
end type
type, extends(A) :: B(lb)
integer, len :: lb
integer matrix(lb, lb)
end type
type, extends(B) :: C(lc1, lc2, lc3)
integer, len :: lc1, lc2, lc3
integer array(lc1, lc2, lc3)
end type
integer l
character(len=*), pointer :: ac1, ac2(:)
character*(*), allocatable :: ac3(:)
character*(:), allocatable :: dc1
character(len=:), pointer :: dc2(:)
character(len=l), pointer :: ec1
character*5, allocatable :: ec2(:)
class(A(*)), pointer :: aa
type(B(* , 5)), allocatable :: ab(:)
type(B(* , *)), pointer :: ab2(:)
class(A(l)), allocatable :: ea
type(B(5 , 5)), pointer :: eb(:)
class(A(:)), allocatable :: da
type(B(: , 5)), pointer :: db(:)
class(*), allocatable :: whatever
type(C(la=*, lb=:, lc1=*, lc2=5, lc3=*)), pointer :: something(:)
type(C(la=*, lb=:, lc1=5, lc2=5, lc3=*)), pointer :: something_else(:)
! OK
allocate(character(len=*):: ac1, ac3(3))
allocate(character*(*):: ac2(5))
allocate(B(*, 5):: aa, ab(2)) !OK but segfault GCC
allocate(B(*, *):: ab2(2))
allocate(C(la=*, lb=10, lc1=*, lc2=5, lc3=*):: something(5))
allocate(C(la=*, lb=10, lc1=2, lc2=5, lc3=3):: aa)
allocate(character(5):: whatever)
! Not OK
! Should be * or no type-spec
!ERROR: Type parameters in type-spec must be assumed if and only if they are assumed for allocatable object in ALLOCATE
allocate(character(len=5):: ac1)
!ERROR: Type parameters in type-spec must be assumed if and only if they are assumed for allocatable object in ALLOCATE
!ERROR: Type parameters in type-spec must be assumed if and only if they are assumed for allocatable object in ALLOCATE
allocate(character(len=5):: ac2(3), ac3)
!ERROR: Type parameters in type-spec must be assumed if and only if they are assumed for allocatable object in ALLOCATE
allocate(character(len=l):: ac1)
!ERROR: Type parameters in type-spec must be assumed if and only if they are assumed for allocatable object in ALLOCATE
!ERROR: Type parameters in type-spec must be assumed if and only if they are assumed for allocatable object in ALLOCATE
allocate(character(len=l):: ac2(3), ac3)
!ERROR: Type parameters in type-spec must be assumed if and only if they are assumed for allocatable object in ALLOCATE
allocate(A(5):: aa)
!ERROR: Type parameters in type-spec must be assumed if and only if they are assumed for allocatable object in ALLOCATE
allocate(B(5, 5):: ab(5))
!ERROR: Type parameters in type-spec must be assumed if and only if they are assumed for allocatable object in ALLOCATE
!ERROR: Type parameters in type-spec must be assumed if and only if they are assumed for allocatable object in ALLOCATE
allocate(B(l, 5):: aa, ab(5))
! Must not be *
!ERROR: Type parameters in type-spec must be assumed if and only if they are assumed for allocatable object in ALLOCATE
allocate(character(len=*):: ac1, dc1, ac3(2))
!ERROR: Type parameters in type-spec must be assumed if and only if they are assumed for allocatable object in ALLOCATE
allocate(character*(*):: dc2(5))
!ERROR: Type parameters in type-spec must be assumed if and only if they are assumed for allocatable object in ALLOCATE
allocate(character*(*):: ec1)
!ERROR: Type parameters in type-spec must be assumed if and only if they are assumed for allocatable object in ALLOCATE
allocate(character(*):: whatever)
!ERROR: Type parameters in type-spec must be assumed if and only if they are assumed for allocatable object in ALLOCATE
allocate(character(len=*):: ac2(5), ec2(5))
!ERROR: Type parameters in type-spec must be assumed if and only if they are assumed for allocatable object in ALLOCATE
allocate(A(*):: ea) !segfault gfortran
!ERROR: Type parameters in type-spec must be assumed if and only if they are assumed for allocatable object in ALLOCATE
allocate(B(*, 5):: eb(2)) !segfault gfortran
!ERROR: Type parameters in type-spec must be assumed if and only if they are assumed for allocatable object in ALLOCATE
allocate(A(*):: da) !segfault gfortran
!ERROR: Type parameters in type-spec must be assumed if and only if they are assumed for allocatable object in ALLOCATE
allocate(B(*, 5):: db(2)) !segfault gfortran
!ERROR: Type parameters in type-spec must be assumed if and only if they are assumed for allocatable object in ALLOCATE
allocate(A(*):: aa, whatever)
!ERROR: Type parameters in type-spec must be assumed if and only if they are assumed for allocatable object in ALLOCATE
allocate(B(*, *):: aa)
!ERROR: Type parameters in type-spec must be assumed if and only if they are assumed for allocatable object in ALLOCATE
allocate(C(la=*, lb=10, lc1=*, lc2=5, lc3=*):: something_else(5))
!ERROR: Type parameters in type-spec must be assumed if and only if they are assumed for allocatable object in ALLOCATE
allocate(C(la=5, lb=10, lc1=4, lc2=5, lc3=3):: aa)
!ERROR: Type parameters in type-spec must be assumed if and only if they are assumed for allocatable object in ALLOCATE
allocate(C(la=*, lb=10, lc1=*, lc2=5, lc3=*):: aa)
end subroutine