File: allocate12.f90

package info (click to toggle)
llvm-toolchain-11 1%3A11.0.1-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 995,808 kB
  • sloc: cpp: 4,767,656; ansic: 760,916; asm: 477,436; python: 170,940; objc: 69,804; lisp: 29,914; sh: 23,855; f90: 18,173; pascal: 7,551; perl: 7,471; ml: 5,603; awk: 3,489; makefile: 2,573; xml: 915; cs: 573; fortran: 503; javascript: 452
file content (118 lines) | stat: -rw-r--r-- 4,553 bytes parent folder | download | duplicates (2)
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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
! RUN: %S/test_errors.sh %s %t %f18
! Check for semantic errors in ALLOCATE statements

subroutine C941_C942b_C950(xsrc, x1, a2, b2, cx1, ca2, cb1, cb2, c1)
! C941: An allocate-coarray-spec shall appear if and only if the allocate-object
! is a coarray.
  type type0
    real, allocatable :: array(:)
  end type
  type type1
    class(type0), pointer :: t0
  end type

  type type2
    type(type1), pointer :: t1(:)
  end type

  type A
    real x(10)
  end type

  type B
    real, allocatable :: x(:)
  end type

  type C
    class(type2), allocatable :: ct2(:, :)[:, :, :]
    class(A), allocatable :: cx(:, :)[:, :, :]
    class(A), allocatable :: x(:, :)
  end type

  real :: xsrc(10)
  real, allocatable :: x1, x2(:)
  class(A), pointer :: a1, a2(:)

  real, allocatable :: cx1[:], cx2(:)[:, :]
  class(A), allocatable :: ca1[:, :], ca2(:)[:]

  type(B) :: b1, b2(*)
  type(B) :: cb1[5:*], cb2(*)[2, -1:*]

  type(C) :: c1

  class(*), allocatable :: var(:), cvar(:)[:]

  ! Valid constructs
  allocate(x1, x2(10), cx1[*], cx2(10)[2, -1:*])
  allocate(a1, a2(10), ca1[2, -1:*], ca2(10)[*])
  allocate(b1%x, b2(1)%x, cb1%x, cb2(1)%x, SOURCE=xsrc)
  allocate(c1%x(-1:10, 1:5), c1%cx(-1:10, 1:5)[-1:5, 1:2, 2:*])
  allocate(A:: var(5), cvar(10)[*])


  !ERROR: Coarray specification must not appear in ALLOCATE when allocatable object is not a coarray
  allocate(x1[*])
  !ERROR: Coarray specification must not appear in ALLOCATE when allocatable object is not a coarray
  allocate(x2(10)[*])
  !ERROR: Coarray specification must appear in ALLOCATE when allocatable object is a coarray
  allocate(cx1)
  !ERROR: Coarray specification must appear in ALLOCATE when allocatable object is a coarray
  allocate(cx2(10))

  !ERROR: Coarray specification must not appear in ALLOCATE when allocatable object is not a coarray
  allocate(cx1[*], a1[*])
  !ERROR: Coarray specification must not appear in ALLOCATE when allocatable object is not a coarray
  allocate(cx1[*], a2(10)[*])
  !ERROR: Coarray specification must appear in ALLOCATE when allocatable object is a coarray
  allocate(x1, ca1)
  !ERROR: Coarray specification must appear in ALLOCATE when allocatable object is a coarray
  allocate(ca1[2, -1:*], ca2(10))

  !ERROR: Coarray specification must not appear in ALLOCATE when allocatable object is not a coarray
  allocate(b1%x[5:*] , SOURCE=xsrc)
  !ERROR: Coarray specification must not appear in ALLOCATE when allocatable object is not a coarray
  allocate(b2(1)%x[2, -1:*], SOURCE=xsrc)
  !ERROR: Coarray specification must not appear in ALLOCATE when allocatable object is not a coarray
  allocate(cb1%x[5:*] , SOURCE=xsrc)
  !ERROR: Coarray specification must not appear in ALLOCATE when allocatable object is not a coarray
  allocate(cb2(1)%x[2, -1:*], SOURCE=xsrc)

  !ERROR: Coarray specification must not appear in ALLOCATE when allocatable object is not a coarray
  allocate(c1%x(-1:10, 1:5)[-1:5, 1:2, 2:*])
  !ERROR: Coarray specification must appear in ALLOCATE when allocatable object is a coarray
  allocate(c1%cx(-1:10, 1:5))

  !ERROR: Coarray specification must not appear in ALLOCATE when allocatable object is not a coarray
  allocate(A:: var(5)[*], cvar(10)[*])
  !ERROR: Coarray specification must appear in ALLOCATE when allocatable object is a coarray
  allocate(A:: var(5), cvar(10))

! C942b: [... (shape related stuff not tested here) ...]. The number of
! allocate-coshape-specs in an allocate-coarray-spec shall be one less
! than the corank of the allocate-object.

  ! Valid constructs already tested above

  !ERROR: Corank of coarray specification in ALLOCATE must match corank of alloctable coarray
  allocate(cx1[2,-1:*], cx2(10)[2, -1:*])
  !ERROR: Corank of coarray specification in ALLOCATE must match corank of alloctable coarray
  allocate(ca1[*], ca2(10)[*])
  !ERROR: Corank of coarray specification in ALLOCATE must match corank of alloctable coarray
  allocate(c1%cx(-1:10, 1:5)[-1:5, 1:*])
  !ERROR: Corank of coarray specification in ALLOCATE must match corank of alloctable coarray
  allocate(A:: cvar(10)[2,2,*])

! C950: An allocate-object shall not be a coindexed object.

  ! Valid construct
  allocate(c1%ct2(2,5)%t1(2)%t0%array(10))

  !ERROR: Allocatable object must not be coindexed in ALLOCATE
  allocate(b1%x, b2(1)%x, cb1[2]%x, SOURCE=xsrc)
  !ERROR: Allocatable object must not be coindexed in ALLOCATE
  allocate(b1%x, b2(1)%x, cb2(1)[2,-1]%x, MOLD=xsrc)
  !ERROR: Allocatable object must not be coindexed in ALLOCATE
  allocate(c1%ct2(2,5)[1,1,1]%t1(2)%t0%array(10))

end subroutine