1! RUN: %python %S/test_errors.py %s %flang_fc1
2! C1167 -- An exit-stmt shall not appear within a DO CONCURRENT construct if
3! it belongs to that construct or an outer construct.
4
5subroutine do_concurrent_test1(n)
6  implicit none
7  integer :: i1,i2,i3,i4,i5,i6,n
8  mytest1: if (n>0) then
9  nc1:       do concurrent(i1=1:n)
10  nc2:         do i2=1,n
11  nc3:           do concurrent(i3=1:n)
12  nc4:             do i4=1,n
13  nc5:               do concurrent(i5=1:n)
14  nc6:                 do i6=1,n
15!ERROR: EXIT must not leave a DO CONCURRENT statement
16!ERROR: EXIT must not leave a DO CONCURRENT statement
17!ERROR: EXIT must not leave a DO CONCURRENT statement
18                         if (i6==10) exit mytest1
19                       end do nc6
20                     end do nc5
21                   end do nc4
22                 end do nc3
23               end do nc2
24             end do nc1
25           end if mytest1
26end subroutine do_concurrent_test1
27
28subroutine do_concurrent_test2(n)
29  implicit none
30  integer :: i1,i2,i3,i4,i5,i6,n
31  mytest2: if (n>0) then
32  nc1:       do concurrent(i1=1:n)
33  nc2:         do i2=1,n
34  nc3:           do concurrent(i3=1:n)
35  nc4:             do i4=1,n
36  nc5:               do concurrent(i5=1:n)
37  nc6:                 do i6=1,n
38!ERROR: EXIT must not leave a DO CONCURRENT statement
39!ERROR: EXIT must not leave a DO CONCURRENT statement
40                         if (i6==10) exit nc3
41                       end do nc6
42                     end do nc5
43                   end do nc4
44                 end do nc3
45               end do nc2
46             end do nc1
47           end if mytest2
48end subroutine do_concurrent_test2
49
50subroutine do_concurrent_test3(n)
51  implicit none
52  integer :: i1,i2,i3,i4,i5,i6,n
53  mytest3: if (n>0) then
54  nc1:       do concurrent(i1=1:n)
55  nc2:         do i2=1,n
56  nc3:           do concurrent(i3=1:n)
57!ERROR: EXIT must not leave a DO CONCURRENT statement
58                   if (i3==4) exit nc2
59  nc4:             do i4=1,n
60  nc5:               do concurrent(i5=1:n)
61  nc6:                 do i6=1,n
62                         if (i6==10) print *, "hello"
63                       end do nc6
64                     end do nc5
65                   end do nc4
66                 end do nc3
67               end do nc2
68             end do nc1
69           end if mytest3
70end subroutine do_concurrent_test3
71