1 ! RUN: %python %S/../test_errors.py %s %flang -fopenmp
3 ! 2.13.3 parallel sections Construct
4 ! The restrictions for the parallel construct and the sections construct apply
5 program OmpConstructSections01
7 integer :: section_count
= 0
8 integer, parameter :: NT
= 4
9 integer :: i
, array(10)
13 type(my_type
) :: my_var
14 print *, 'section_count', section_count
18 !ERROR: A variable that is part of another variable (as an array or structure element) cannot appear in a PRIVATE or SHARED clause
19 !$omp parallel sections shared(array(i))
20 !$omp end parallel sections
21 !ERROR: A variable that is part of another variable (as an array or structure element) cannot appear in a PRIVATE or SHARED clause
22 !$omp parallel sections shared(my_var%array)
23 !$omp end parallel sections
25 !ERROR: invalid branch into an OpenMP structured block
26 !ERROR: invalid branch into an OpenMP structured block
27 !ERROR: invalid branch into an OpenMP structured block
29 !ERROR: invalid branch into an OpenMP structured block
31 !ERROR: A variable that is part of another variable (as an array or structure element) cannot appear in a PRIVATE or SHARED clause
32 !$omp parallel sections private(my_var%array)
34 print *, "This is a single statement structured block"
36 open (10, file
="random-file-name.txt", err
=30)
37 !ERROR: invalid branch into an OpenMP structured block
38 !ERROR: invalid branch leaving an OpenMP structured block
39 open (10, file
="random-file-name.txt", err
=40)
41 section_count
= section_count
+ 1
42 20 print *, 'Entering into section'
43 call calledFromWithinSection()
44 print *, 'section_count', section_count
46 section_count
= section_count
+ 1
47 print *, 'section_count', section_count
48 !ERROR: invalid branch leaving an OpenMP structured block
51 30 print *, "Error in opening file"
52 !$omp end parallel sections
53 10 print *, 'Jump from section'
54 !ERROR: A variable that is part of another variable (as an array or structure element) cannot appear in a PRIVATE or SHARED clause
55 !$omp parallel sections private(array(i))
57 40 print *, 'Error in opening file'
58 !$omp end parallel sections
59 end program OmpConstructSections01
61 function returnFromSections()
62 !$omp parallel sections
64 !ERROR: RETURN statement is not allowed in a PARALLEL SECTIONS construct
66 !$omp end parallel sections
69 subroutine calledFromWithinSection()
70 print *, "I am called from within a 'section' structured block"
72 end subroutine calledFromWithinSection
74 subroutine continueWithinSections()
77 print *, "Statement within loop but outside section construct"
78 !$omp parallel sections
81 !ERROR: CYCLE to construct outside of PARALLEL SECTIONS construct is not allowed
84 !$omp end parallel sections
85 print *, "Statement within loop but outside section contruct"
88 !$omp parallel sections
93 !$omp end parallel sections
95 !$omp parallel sections
102 !$omp end parallel sections
105 !$omp parallel sections
108 !ERROR: CYCLE to construct 'loop_2' outside of PARALLEL SECTIONS construct is not allowed
111 !$omp end parallel sections
113 end subroutine continueWithinSections
115 subroutine breakWithinSections()
117 !$omp parallel sections
120 !ERROR: EXIT to construct 'loop_3' outside of PARALLEL SECTIONS construct is not allowed
123 !$omp end parallel sections
127 !$omp parallel sections
130 !ERROR: EXIT to construct outside of PARALLEL SECTIONS construct is not allowed
133 !$omp end parallel sections
136 !$omp parallel sections
143 !$omp end parallel sections
145 !$omp parallel sections
152 !$omp end parallel sections
153 end subroutine breakWithinSections