aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.9/gcc/testsuite/gfortran.dg/coarray_4.f90
blob: cdc4ef88e732a9518eea0b4d6403f557d0c964dc (plain)
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
! { dg-do compile }
! { dg-options "-fcoarray=single" }
!
! Coarray support -- corank declarations
! PR fortran/18918
!

subroutine valid(n, c, f)
  implicit none
  integer :: n
  integer, save :: a[*], b(4)[-1:4,*]
  real :: c(*)[1,0:3,3:*]
  real :: f(n)[0:n,-100:*]
  integer, allocatable :: d[:], e(:)[:,:]
  integer, save, codimension[1,*] :: g, h(7), i(6)[*], j[*]
  integer :: k
  codimension :: k[*]
  save :: k
  integer :: ii = 7
  block
    integer :: j = 5
    integer, save :: kk[j, *] ! { dg-error "Variable .j. cannot appear in the expression" }
  end block
end subroutine valid

subroutine valid2()
  type t
    integer, allocatable :: a[:]
  end type t
  type, extends(t) :: tt
    integer, allocatable :: b[:]
  end type tt
  type(tt), save :: foo
  type(tt) :: bar
end subroutine valid2

subroutine invalid(n)
  implicit none
  integer :: n
  integer :: k[*] ! { dg-error "not ALLOCATABLE, SAVE nor a dummy" }
  integer :: h(3)[*] ! { dg-error "not ALLOCATABLE, SAVE nor a dummy" }
  integer, save :: a[*]
  codimension :: a[1,*] ! { dg-error "Duplicate CODIMENSION attribute" }
  complex, save :: hh(n)[*] ! { dg-error "cannot have the SAVE attribute" }
  integer :: j = 6

  integer, save :: hf1[j,*] ! { dg-error "cannot appear in the expression" }
  integer, save :: hf2[n,*] ! OK
  integer, save :: hf3(4)[j,*] ! { dg-error "cannot appear in the expression|cannot have the SAVE attribute" }
  integer, save :: hf4(5)[n,*] ! OK

  integer, allocatable :: a2[*] ! { dg-error "must have deferred shape" }
  integer, allocatable :: a3(:)[*] ! { dg-error "must have deferred shape" }
  integer, allocatable :: a4[*] ! { dg-error "must have deferred shape" }
end subroutine invalid

subroutine invalid2
  use iso_c_binding
  implicit none
  type t0
    integer, allocatable :: a[:,:,:]
  end type t0
  type t
  end type t
  type, extends(t) :: tt ! { dg-error "has a coarray component, parent type" }
    integer, allocatable :: a[:]
  end type tt
  type ttt
    integer, pointer :: a[:] ! { dg-error "must be allocatable" }
  end type ttt
  type t4
    integer, allocatable :: b[4,*] ! { dg-error "with deferred shape" }
  end type t4
  type t5
    type(c_ptr), allocatable :: p[:] ! { dg-error "shall not be a coarray" }
  end type t5
  type(t0), save :: t0_1[*] ! { dg-error "shall be a nonpointer, nonallocatable scalar" }
  type(t0), allocatable :: t0_2[:] ! { dg-error "shall be a nonpointer, nonallocatable scalar" }
  type(c_ptr), save :: pp[*] ! { dg-error "shall not be a coarray" }
end subroutine invalid2

elemental subroutine elem(a) ! { dg-error "Coarray dummy argument" }
  integer, intent(in) :: a[*]
end subroutine

function func() result(res)
  integer :: res[*] ! { dg-error "CODIMENSION attribute conflicts with RESULT" }
end function func