142 lines · plain
1! REQUIRES: openmp_runtime2 3! RUN: %python %S/../test_errors.py %s %flang %openmp_flags4! OpenMP version 5.0.05! 2.8.1 sections construct6! The code enclosed in a sections construct must be a structured block.7program OmpConstructSections018 use omp_lib9 integer :: section_count = 010 integer, parameter :: NT = 411 print *, 'section_count', section_count12!ERROR: invalid branch into an OpenMP structured block13!ERROR: invalid branch into an OpenMP structured block14!ERROR: invalid branch into an OpenMP structured block15 if (NT) 20, 30, 4016!ERROR: invalid branch into an OpenMP structured block17 goto 2018!$omp sections19 !$omp section20 print *, "This is a single statement structured block"21 !$omp section22 !ERROR: invalid branch into an OpenMP structured block23 !ERROR: invalid branch leaving an OpenMP structured block24 open (10, file="random-file-name.txt", err=30)25 !ERROR: invalid branch into an OpenMP structured block26 !ERROR: invalid branch leaving an OpenMP structured block27 open (10, file="random-file-name.txt", err=40)28 !$omp section29 section_count = section_count + 13020 print *, 'Entering into section'31 call calledFromWithinSection()32 print *, 'section_count', section_count33 !$omp section34 section_count = section_count + 135 print *, 'section_count', section_count36 !ERROR: invalid branch leaving an OpenMP structured block37 goto 1038 !$omp section3930 print *, "Error in opening file"40!$omp end sections4110 print *, 'Jump from section'42 43!$omp sections44 !$omp section4540 print *, 'Error in opening file'46!$omp end sections47end program OmpConstructSections0148 49function returnFromSections()50 !$omp sections51 !$omp section52 !ERROR: RETURN statement is not allowed in a SECTIONS construct53 RETURN54 !$omp end sections55end function56 57subroutine calledFromWithinSection()58 print *, "I am called from within a 'section' structured block"59 return60end subroutine calledFromWithinSection61 62subroutine continueWithinSections()63 integer i64 do i = 1, 1065 print *, "Statement within loop but outside section construct"66 !$omp sections67 !$omp section68 IF (i .EQ. 5) THEN69 !ERROR: CYCLE to construct outside of SECTIONS construct is not allowed70 CYCLE71 END IF72 !$omp end sections73 print *, "Statement within loop but outside section contruct"74 end do75 76 !$omp sections77 !$omp section78 do i = 1, 1079 CYCLE80 end do81 !$omp end sections82 83 !$omp sections84 !$omp section85 loop_1: do i = 1, 1086 IF (i .EQ. 5) THEN87 CYCLE loop_188 END IF89 end do loop_190 !$omp end sections91 92 loop_2: do i = 1, 1093 !$omp sections94 !$omp section95 IF (i .EQ. 5) THEN96 !ERROR: CYCLE to construct 'loop_2' outside of SECTIONS construct is not allowed97 CYCLE loop_298 END IF99 !$omp end sections100 end do loop_2101end subroutine continueWithinSections102 103subroutine breakWithinSections()104 loop_3: do i = 1, 10105 !$omp sections106 !$omp section107 IF (i .EQ. 5) THEN108 !ERROR: EXIT to construct 'loop_3' outside of SECTIONS construct is not allowed109 EXIT loop_3110 END IF111 !$omp end sections112 end do loop_3113 114 loop_4: do i = 1, 10115 !$omp sections116 !$omp section117 IF (i .EQ. 5) THEN118 !ERROR: EXIT to construct outside of SECTIONS construct is not allowed119 EXIT120 END IF121 !$omp end sections122 end do loop_4123 124 !$omp sections125 !$omp section126 do i = 1, 10127 IF (i .EQ. 5) THEN128 EXIT129 END IF130 end do131 !$omp end sections132 133 !$omp sections134 !$omp section135 loop_5: do i = 1, 10136 IF (i .EQ. 5) THEN137 EXIT loop_5138 END IF139 end do loop_5140 !$omp end sections141end subroutine breakWithinSections142