Plugins: Add label-text.h to CPPLIB_H so it will be installed [PR115288]
[official-gcc.git] / gcc / testsuite / gfortran.dg / impure_assignment_3.f90
blob8be19896ef59cafbb2c9c461014a6638cafa7d00
1 ! { dg-do compile }
3 ! PR 43169: [OOP] gfortran rejects PURE procedure with SELECT TYPE construct
5 ! Original test case by Todd Hay <haymaker@mail.utexas.edu>
6 ! Modified by Janus Weil <janus@gcc.gnu.org>
8 implicit none
9 real :: g
11 contains
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
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
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
44 end