File: allocate02.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 (49 lines) | stat: -rw-r--r-- 1,908 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
! RUN: %S/test_errors.sh %s %t %f18

! Check for semantic errors in ALLOCATE statements

subroutine C943_C944(src, src2)
! C943
! No alloc-opt shall appear more than once in a given alloc-opt-list.
  character(50) msg
  integer stat, stat2
  real src(2:4), src2(2:4)
  real mld(2:4), mld2(2:4)
  real, allocatable :: x1(:), x2(:), x3(:), x4(:), x5(:), x6(:), x7(:), x8(:), x9(:)
  real, allocatable :: y1(:), y2(:), y3(:), y4(:)
  real, pointer :: p1, p2

  !Nominal cases, no error expected
  allocate(x1, source=src)
  allocate(x2, mold=mld)
  allocate(x3(2:4), stat=stat)
  allocate(x4(2:4), stat=stat, errmsg=msg)
  allocate(x5(2:4), source=src, stat=stat, errmsg=msg)

  !ERROR: STAT may not be duplicated in a ALLOCATE statement
  allocate(x6, stat=stat, source=src, stat=stat2)

  !ERROR: SOURCE may not be duplicated in a ALLOCATE statement
  allocate(x7, source=src, stat=stat, source=src2)

  !ERROR: MOLD may not be duplicated in a ALLOCATE statement
  allocate(x8, mold=mld, stat=stat, mold=mld)

  !ERROR: ERRMSG may not be duplicated in a ALLOCATE statement
  allocate(x9, mold=mld, errmsg=msg, stat=stat, errmsg= msg)

! C944
! At most one of source-expr and type-spec must appear.

  !Nominal cases already tested in C943 and type-spec tests (e.g C934)

  !ERROR: At most one of source-expr and type-spec may appear in a ALLOCATE statement
  allocate(real:: y1, source=src)
  !ERROR: At most one of source-expr and type-spec may appear in a ALLOCATE statement
  allocate(real:: y2, mold=mld)
  !ERROR: At most one of source-expr and type-spec may appear in a ALLOCATE statement
  allocate(y3, source=src, stat=stat, errmsg=msg, mold=mld)
  !ERROR: At most one of source-expr and type-spec may appear in a ALLOCATE statement
  !ERROR: At most one of source-expr and type-spec may appear in a ALLOCATE statement
  allocate(real:: y4, source=src, stat=stat, errmsg=msg, mold=mld)
end subroutine