| 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) |
| 6 |
|
| 7 |
a = 0 |
| 8 |
|
| 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 |
| 14 |
|
| 15 |
i1: if (i > 0) then |
| 16 |
end if ! { dg-error "Expected block name of .... in END IF statement" } |
| 17 |
end if i1 |
| 18 |
|
| 19 |
s1: select case (i) |
| 20 |
end select ! { dg-error "Expected block name of .... in END SELECT statement" } |
| 21 |
end select s1 |
| 22 |
|
| 23 |
w1: where (a > 0) |
| 24 |
end where ! { dg-error "Expected block name of .... in END WHERE statement" } |
| 25 |
end where w1 |
| 26 |
|
| 27 |
f1: forall (i = 1:10) |
| 28 |
end forall ! { dg-error "Expected block name of .... in END FORALL statement" } |
| 29 |
end forall f1 |
| 30 |
|
| 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 |
| 38 |
|
| 39 |
if (i > 0) then |
| 40 |
else if (i ==0) then i2 ! { dg-error "Syntax error in ELSE IF statement" } |
| 41 |
else i2 ! { dg-error "Invalid character.s. in ELSE statement" } |
| 42 |
end if i2 ! { dg-error "Syntax error in END IF statement" } |
| 43 |
end if |
| 44 |
|
| 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 |
| 50 |
|
| 51 |
where (a > 0) |
| 52 |
elsewhere w2 ! { dg-error "Invalid character.s. in ELSE statement" } |
| 53 |
end where w2 ! { dg-error "Syntax error in END WHERE statement" } |
| 54 |
end where |
| 55 |
|
| 56 |
forall (i=1:10) |
| 57 |
end forall f2 ! { dg-error "Syntax error in END FORALL statement" } |
| 58 |
end forall |
| 59 |
|
| 60 |
end program blocks |