OSDN Git Service

2011-09-26 Janus Weil <janus@gcc.gnu.org>
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / gfortran.dg / impure_assignment_3.f90
1 ! { dg-do compile }
2 !
3 ! PR 43169: [OOP] gfortran rejects PURE procedure with SELECT TYPE construct
4 !
5 ! Original test case by Todd Hay <haymaker@mail.utexas.edu>
6 ! Modified by Janus Weil <janus@gcc.gnu.org>
7
8   implicit none
9   real :: g
10
11 contains
12
13   pure subroutine sub1(x)
14     type :: myType
15       real :: a
16     end type myType
17     class(myType), intent(inout) :: x
18     real :: r3
19     select type(x)
20     class is (myType)
21       x%a = 42.
22       r3 =  43.
23       g = 44.             ! { dg-error "variable definition context" }
24     end select
25   end subroutine
26
27   pure subroutine sub2
28     real :: r1
29     block
30       real :: r2
31       r1 = 45.
32       r2 = 46.
33       g = 47.             ! { dg-error "variable definition context" }
34     end block
35   end subroutine
36
37   pure subroutine sub3
38     block
39       integer, save :: i  ! { dg-error "cannot be specified in a PURE procedure" }
40       integer :: j = 5    ! { dg-error "is not allowed in a PURE procedure" }
41     end block
42   end subroutine
43
44 end