PR target/83368
[official-gcc.git] / gcc / testsuite / gfortran.dg / block_name_2.f90
blobd86e77e7a8c93b93fa6855453c80282b1cd7d843
1 ! { dg-do compile }
2 ! Test that various illegal combinations of block statements with
3 ! block names yield the correct error messages. Motivated by PR31471.
4 program blocks
5 dimension a(5,2)
7 a = 0
9 ! The END statement of a labelled block needs to carry the construct
10 ! name.
11 d1: do i=1,10
12 end do ! { dg-error "Expected block name of .... in END DO statement" }
13 end do d1
15 i1: if (i > 0) then
16 end if ! { dg-error "Expected block name of .... in END IF statement" }
17 end if i1
19 s1: select case (i)
20 end select ! { dg-error "Expected block name of .... in END SELECT statement" }
21 end select s1
23 w1: where (a > 0)
24 end where ! { dg-error "Expected block name of .... in END WHERE statement" }
25 end where w1
27 f1: forall (i = 1:10)
28 end forall ! { dg-error "Expected block name of .... in END FORALL statement" }
29 end forall f1
31 ! A construct name may not appear in the END statement, if it
32 ! doesn't appear in the statement beginning the block.
33 ! Likewise it may not appear in ELSE IF, ELSE, ELSEWHERE or CASE
34 ! statements.
35 do i=1,10
36 end do d2 ! { dg-error "Syntax error in END DO statement" }
37 end do
39 if (i > 0) then
40 else if (i ==0) then i2 ! { dg-error "Unexpected junk after ELSE IF statement" }
41 else i2 ! { dg-error "Unexpected junk after ELSE statement" }
42 end if i2 ! { dg-error "Syntax error in END IF statement" }
43 end if
45 select case (i)
46 case (1) s2 ! { dg-error "Syntax error in CASE specification" }
47 case default s2 ! { dg-error "Syntax error in CASE specification" }
48 end select s2 ! { dg-error "Syntax error in END SELECT statement" }
49 end select
51 where (a > 0)
52 elsewhere w2 ! { dg-error "Unexpected junk after ELSE statement" }
53 end where w2 ! { dg-error "Syntax error in END WHERE statement" }
54 end where
56 forall (i=1:10)
57 end forall f2 ! { dg-error "Syntax error in END FORALL statement" }
58 end forall
60 end program blocks