1 ! REQUIRES: openmp_runtime
3 ! RUN: %python %S/../test_errors.py %s %flang %openmp_flags
5 ! 2.8.1 sections construct
6 ! The code enclosed in a sections construct must be a structured block.
7 program OmpConstructSections01
9 integer :: section_count
= 0
10 integer, parameter :: NT
= 4
11 print *, 'section_count', section_count
12 !ERROR: invalid branch into an OpenMP structured block
13 !ERROR: invalid branch into an OpenMP structured block
14 !ERROR: invalid branch into an OpenMP structured block
16 !ERROR: invalid branch into an OpenMP structured block
20 print *, "This is a single statement structured block"
22 open (10, file
="random-file-name.txt", err
=30)
23 !ERROR: invalid branch into an OpenMP structured block
24 !ERROR: invalid branch leaving an OpenMP structured block
25 open (10, file
="random-file-name.txt", err
=40)
27 section_count
= section_count
+ 1
28 20 print *, 'Entering into section'
29 call calledFromWithinSection()
30 print *, 'section_count', section_count
32 section_count
= section_count
+ 1
33 print *, 'section_count', section_count
34 !ERROR: invalid branch leaving an OpenMP structured block
37 30 print *, "Error in opening file"
39 10 print *, 'Jump from section'
43 40 print *, 'Error in opening file'
45 end program OmpConstructSections01
47 function returnFromSections()
50 !ERROR: RETURN statement is not allowed in a SECTIONS construct
55 subroutine calledFromWithinSection()
56 print *, "I am called from within a 'section' structured block"
58 end subroutine calledFromWithinSection
60 subroutine continueWithinSections()
63 print *, "Statement within loop but outside section construct"
67 !ERROR: CYCLE to construct outside of SECTIONS construct is not allowed
71 print *, "Statement within loop but outside section contruct"
94 !ERROR: CYCLE to construct 'loop_2' outside of SECTIONS construct is not allowed
99 end subroutine continueWithinSections
101 subroutine breakWithinSections()
106 !ERROR: EXIT to construct 'loop_3' outside of SECTIONS construct is not allowed
116 !ERROR: EXIT to construct outside of SECTIONS construct is not allowed
139 end subroutine breakWithinSections