aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.9/gcc/testsuite/gfortran.dg/do_check_6.f90
blob: 2e18f219f83a2a0116924021d2d3fb15d5586920 (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
! { dg-do compile }
!
! PR fortran/54958
!
module m
  integer, protected :: i
  integer :: j
end module m

subroutine test1()
  use m
  implicit none
  integer :: A(5)
  ! Valid: data-implied-do (has a scope of the statement or construct)
  DATA (A(i), i=1,5)/5*42/ ! OK

  ! Valid: ac-implied-do (has a scope of the statement or construct)
  print *, [(i, i=1,5 )] ! OK

  ! Valid: index-name (has a scope of the statement or construct)
  forall (i = 1:5) ! OK
  end forall

  ! Valid: index-name (has a scope of the statement or construct)
  do concurrent (i = 1:5) ! OK
  end do

  ! Invalid: io-implied-do
  print *, (i, i=1,5 ) ! { dg-error "PROTECTED and can not appear in a variable definition context .iterator variable." }

  ! Invalid: do-variable in a do-stmt
  do i = 1, 5 ! { dg-error "PROTECTED and can not appear in a variable definition context .iterator variable." }
  end do
end subroutine test1

subroutine test2(i)
  implicit none
  integer, intent(in) :: i
  integer :: A(5)
  ! Valid: data-implied-do (has a scope of the statement or construct)
  DATA (A(i), i=1,5)/5*42/ ! OK

  ! Valid: ac-implied-do (has a scope of the statement or construct)
  print *, [(i, i=1,5 )] ! OK

  ! Valid: index-name (has a scope of the statement or construct)
  forall (i = 1:5) ! OK
  end forall

  ! Valid: index-name (has a scope of the statement or construct)
  do concurrent (i = 1:5) ! OK
  end do

  ! Invalid: io-implied-do
  print *, (i, i=1,5 ) ! { dg-error "INTENT.IN. in variable definition context .iterator variable." }

  ! Invalid: do-variable in a do-stmt
  do i = 1, 5 ! { dg-error "INTENT.IN. in variable definition context .iterator variable." }
  end do
end subroutine test2

pure subroutine test3()
  use m
  implicit none
  integer :: A(5)
  !DATA (A(j), j=1,5)/5*42/ ! Not allowed in pure

  ! Valid: ac-implied-do (has a scope of the statement or construct)
  A = [(j, j=1,5 )] ! OK

  ! Valid: index-name (has a scope of the statement or construct)
  forall (j = 1:5) ! OK
  end forall

  ! Valid: index-name (has a scope of the statement or construct)
  do concurrent (j = 1:5) ! OK
  end do

  ! print *, (j, j=1,5 ) ! I/O not allowed in PURE

  ! Invalid: do-variable in a do-stmt
  do j = 1, 5 ! { dg-error "variable definition context .iterator variable. at .1. in PURE procedure" }
  end do
end subroutine test3