2008-07-06 Kai Tietz <kai.tietz@onevision.com>
[official-gcc.git] / gcc / testsuite / gfortran.dg / goto_2.f90
blobacff590a9cd724d31dcfa8f5c4d34fb174273bff
1 ! { dg-do run }
2 ! Checks for corrects warnings if branching to then end of a
3 ! construct at various nesting levels
4 subroutine check_if(i)
5 goto 10
6 if (i > 0) goto 40
7 if (i < 0) then
8 goto 40
9 10 end if
10 if (i == 0) then
11 i = i+1
12 goto 20 ! { dg-warning "jumps to END of construct" }
13 goto 40
14 20 end if ! { dg-warning "jumps to END of construct" }
15 if (i == 1) then
16 i = i+1
17 if (i == 2) then
18 goto 30 ! { dg-warning "jumps to END of construct" }
19 end if
20 goto 40
21 30 end if ! { dg-warning "jumps to END of construct" }
22 return
23 40 i = -1
24 end subroutine check_if
26 subroutine check_select(i)
27 goto 10
28 select case (i)
29 case default
30 goto 999
31 10 end select
32 select case (i)
33 case (2)
34 i = 1
35 goto 20 ! { dg-warning "jumps to END of construct" }
36 goto 999
37 case default
38 goto 999
39 20 end select ! { dg-warning "jumps to END of construct" }
40 j = i
41 select case (j)
42 case default
43 select case (i)
44 case (1)
45 i = 2
46 goto 30 ! { dg-warning "jumps to END of construct" }
47 end select
48 goto 999
49 30 end select ! { dg-warning "jumps to END of construct" }
50 return
51 999 i = -1
52 end subroutine check_select
54 i = 0
55 call check_if (i)
56 if (i /= 2) call abort ()
57 call check_select (i)
58 if (i /= 2) call abort ()
59 end