1 ! RUN: %python %S/../test_errors.py %s %flang -fopenmp
3 ! 2.8.1 sections construct
4 ! The code enclosed in a sections construct must be a structured block.
5 program OmpConstructSections01
7 integer :: section_count
= 0
8 integer, parameter :: NT
= 4
9 print *, 'section_count', section_count
10 !ERROR: invalid branch into an OpenMP structured block
11 !ERROR: invalid branch into an OpenMP structured block
12 !ERROR: invalid branch into an OpenMP structured block
14 !ERROR: invalid branch into an OpenMP structured block
18 print *, "This is a single statement structured block"
20 open (10, file
="random-file-name.txt", err
=30)
21 !ERROR: invalid branch into an OpenMP structured block
22 !ERROR: invalid branch leaving an OpenMP structured block
23 open (10, file
="random-file-name.txt", err
=40)
25 section_count
= section_count
+ 1
26 20 print *, 'Entering into section'
27 call calledFromWithinSection()
28 print *, 'section_count', section_count
30 section_count
= section_count
+ 1
31 print *, 'section_count', section_count
32 !ERROR: invalid branch leaving an OpenMP structured block
35 30 print *, "Error in opening file"
37 10 print *, 'Jump from section'
41 40 print *, 'Error in opening file'
43 end program OmpConstructSections01
45 function returnFromSections()
48 !ERROR: RETURN statement is not allowed in a SECTIONS construct
53 subroutine calledFromWithinSection()
54 print *, "I am called from within a 'section' structured block"
56 end subroutine calledFromWithinSection
58 subroutine continueWithinSections()
61 print *, "Statement within loop but outside section construct"
65 !ERROR: CYCLE to construct outside of SECTIONS construct is not allowed
69 print *, "Statement within loop but outside section contruct"
92 !ERROR: CYCLE to construct 'loop_2' outside of SECTIONS construct is not allowed
97 end subroutine continueWithinSections
99 subroutine breakWithinSections()
104 !ERROR: EXIT to construct 'loop_3' outside of SECTIONS construct is not allowed
114 !ERROR: EXIT to construct outside of SECTIONS construct is not allowed
137 end subroutine breakWithinSections