1 ! REQUIRES: openmp_runtime
3 ! RUN: %python %S/../test_errors.py %s %flang %openmp_flags
5 ! 2.13.3 parallel sections Construct
6 ! The restrictions for the parallel construct and the sections construct apply
7 program OmpConstructSections01
9 integer :: section_count
= 0
10 integer, parameter :: NT
= 4
11 integer :: i
, array(10)
15 type(my_type
) :: my_var
16 print *, 'section_count', section_count
20 !ERROR: A variable that is part of another variable (as an array or structure element) cannot appear in a SHARED clause
21 !$omp parallel sections shared(array(i))
22 !$omp end parallel sections
23 !ERROR: A variable that is part of another variable (as an array or structure element) cannot appear in a SHARED clause
24 !$omp parallel sections shared(my_var%array)
25 !$omp end parallel sections
27 !ERROR: invalid branch into an OpenMP structured block
28 !ERROR: invalid branch into an OpenMP structured block
29 !ERROR: invalid branch into an OpenMP structured block
31 !ERROR: invalid branch into an OpenMP structured block
33 !ERROR: A variable that is part of another variable (as an array or structure element) cannot appear in a PRIVATE clause
34 !$omp parallel sections private(my_var%array)
36 print *, "This is a single statement structured block"
38 open (10, file
="random-file-name.txt", err
=30)
39 !ERROR: invalid branch into an OpenMP structured block
40 !ERROR: invalid branch leaving an OpenMP structured block
41 open (10, file
="random-file-name.txt", err
=40)
43 section_count
= section_count
+ 1
44 20 print *, 'Entering into section'
45 call calledFromWithinSection()
46 print *, 'section_count', section_count
48 section_count
= section_count
+ 1
49 print *, 'section_count', section_count
50 !ERROR: invalid branch leaving an OpenMP structured block
53 30 print *, "Error in opening file"
54 !$omp end parallel sections
55 10 print *, 'Jump from section'
56 !ERROR: A variable that is part of another variable (as an array or structure element) cannot appear in a PRIVATE clause
57 !$omp parallel sections private(array(i))
59 40 print *, 'Error in opening file'
60 !$omp end parallel sections
61 end program OmpConstructSections01
63 function returnFromSections()
64 !$omp parallel sections
66 !ERROR: RETURN statement is not allowed in a PARALLEL SECTIONS construct
68 !$omp end parallel sections
71 subroutine calledFromWithinSection()
72 print *, "I am called from within a 'section' structured block"
74 end subroutine calledFromWithinSection
76 subroutine continueWithinSections()
79 print *, "Statement within loop but outside section construct"
80 !$omp parallel sections
83 !ERROR: CYCLE to construct outside of PARALLEL SECTIONS construct is not allowed
86 !$omp end parallel sections
87 print *, "Statement within loop but outside section contruct"
90 !$omp parallel sections
95 !$omp end parallel sections
97 !$omp parallel sections
104 !$omp end parallel sections
107 !$omp parallel sections
110 !ERROR: CYCLE to construct 'loop_2' outside of PARALLEL SECTIONS construct is not allowed
113 !$omp end parallel sections
115 end subroutine continueWithinSections
117 subroutine breakWithinSections()
119 !$omp parallel sections
122 !ERROR: EXIT to construct 'loop_3' outside of PARALLEL SECTIONS construct is not allowed
125 !$omp end parallel sections
129 !$omp parallel sections
132 !ERROR: EXIT to construct outside of PARALLEL SECTIONS construct is not allowed
135 !$omp end parallel sections
138 !$omp parallel sections
145 !$omp end parallel sections
147 !$omp parallel sections
154 !$omp end parallel sections
155 end subroutine breakWithinSections