xref: /llvm-project/flang/test/Semantics/dosemantics06.f90 (revision 6c1ac141d3c98af9738bc77fcb55602cbff7751f)
1! RUN: %python %S/test_errors.py %s %flang_fc1
2! C1131, C1133 -- check valid and invalid DO loop naming
3! C1131 (R1119) If the do-stmt of a do-construct specifies a do-construct-name,
4! the corresponding end-do shall be an end-do-stmt specifying the same
5! do-construct-name. If the do-stmt of a do-construct does not specify a
6! do-construct-name, the corresponding end-do shall not specify a
7! do-construct-name.
8!
9! C1133 (R1119) If the do-stmt is a label-do-stmt, the corresponding end-do
10! shall be identified with the same label.
11
12subroutine s1()
13  implicit none
14  ! Valid construct
15  validdo: do while (.true.)
16      print *, "hello"
17      cycle validdo
18      print *, "Weird to get here"
19    end do validdo
20
21  validdo: do while (.true.)
22      print *, "Hello"
23    end do validdo
24
25  ! Missing name on initial DO
26  do while (.true.)
27      print *, "Hello"
28!ERROR: DO construct name unexpected
29    end do formerlabelmissing
30
31  dolabel: do while (.true.)
32      print *, "Hello"
33!ERROR: DO construct name mismatch
34    end do differentlabel
35
36  dowithcycle: do while (.true.)
37      print *, "Hello"
38!ERROR: CYCLE construct-name is not in scope
39      cycle validdo
40    end do dowithcycle
41
42end subroutine s1
43