114 lines · plain
1! RUN: %python %S/../test_errors.py %s %flang_fc1 -fopenmp2! OpenMP Version 5.23! 5.1.1 - Variables Referenced in a Construct4! Copyprivate must accept variables that are predetermined as private.5 6module m17 integer :: m8end module9 10program omp_copyprivate11 use m112 implicit none13 integer :: i14 integer, save :: j15 integer :: k16 common /c/ k17 real, parameter :: pi = 3.1418 integer :: a1(10)19 20 ! Local variables are private.21 !$omp single22 i = 12323 !$omp end single copyprivate(i)24 !$omp single25 !$omp end single copyprivate(a1)26 27 ! Variables with the SAVE attribute are not private.28 !$omp single29 !ERROR: COPYPRIVATE variable 'j' is not PRIVATE or THREADPRIVATE in outer context30 !$omp end single copyprivate(j)31 32 ! Common block variables are not private.33 !$omp single34 !ERROR: COPYPRIVATE variable 'k' is not PRIVATE or THREADPRIVATE in outer context35 !$omp end single copyprivate(/c/)36 !$omp single37 !ERROR: COPYPRIVATE variable 'k' is not PRIVATE or THREADPRIVATE in outer context38 !$omp end single copyprivate(k)39 40 ! Module variables are not private.41 !$omp single42 !ERROR: COPYPRIVATE variable 'm' is not PRIVATE or THREADPRIVATE in outer context43 !$omp end single copyprivate(m)44 45 ! Parallel can make a variable shared.46 !$omp parallel47 !$omp single48 i = 45649 !ERROR: COPYPRIVATE variable 'i' is not PRIVATE or THREADPRIVATE in outer context50 !$omp end single copyprivate(i)51 call sub(j, a1)52 !$omp end parallel53 54 !$omp parallel shared(i)55 !$omp single56 i = 45657 !ERROR: COPYPRIVATE variable 'i' is not PRIVATE or THREADPRIVATE in outer context58 !$omp end single copyprivate(i)59 !$omp end parallel60 61 !FIXME: an error should be emitted in this case.62 ! copyprivate(i) should be considered as a reference to i and a new63 ! symbol should be created in `parallel` scope, for this case to be64 ! handled properly.65 !$omp parallel66 !$omp single67 !$omp end single copyprivate(i)68 !$omp end parallel69 70 ! Named constants are shared.71 !$omp single72 !ERROR: COPYPRIVATE variable 'pi' is not PRIVATE or THREADPRIVATE in outer context73 !ERROR: 'pi' must be a variable74 !$omp end single copyprivate(pi)75 76 !$omp parallel do77 do i = 1, 1078 !$omp parallel79 !$omp single80 j = i81 !ERROR: COPYPRIVATE variable 'i' is not PRIVATE or THREADPRIVATE in outer context82 !$omp end single copyprivate(i)83 !$omp end parallel84 end do85 !$omp end parallel do86 87contains88 subroutine sub(s1, a)89 integer :: s190 integer :: a(:)91 92 ! Dummy argument.93 !$omp single94 !$omp end single copyprivate(s1)95 96 ! Assumed shape arrays are shared.97 !$omp single98 !ERROR: COPYPRIVATE variable 'a' is not PRIVATE or THREADPRIVATE in outer context99 !$omp end single copyprivate(a)100 end subroutine101 102 integer function fun(f1)103 integer :: f1104 105 ! Dummy argument.106 !$omp single107 !$omp end single copyprivate(f1)108 109 ! Function result is private.110 !$omp single111 !$omp end single copyprivate(fun)112 end function113end program114