[PATCH] D92732: [Flang][OpenMP 4.5] Add semantic check for OpenMP Do Loop Constructs

Yashaswini Hegde via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 3 21:55:21 PST 2021


yhegde marked an inline comment as done.
yhegde added inline comments.


================
Comment at: flang/lib/Semantics/resolve-directives.cpp:1039
   }
+  ClearThreadPrivateSymbols();
   PopContext();
----------------
kiranchandramohan wrote:
> Will this work if there are two omp do loops having threadprivate iteration variables?
For the the following test case

program omp_do1
  integer, save:: i, j, k, n
  !$omp  threadprivate(i)
  !$omp  do
  !ERROR: Loop iteration variable i is not allowed in THREADPRIVATE.
  do i = 1, 10
    !!$omp  threadprivate(j)
    !$omp  do
    do j = 1, 10
      print *, "Hello"
    end do
  end do
  !$omp end do

  !$omp  do
  !ERROR: Loop iteration variable i is not allowed in THREADPRIVATE.
  do i = 1, 10
    !!$omp  threadprivate(j)
    !$omp  do
    do j = 1, 10
      print *, "Hello"
    end do
  end do
  !$omp end do

end program omp_do1

the error is 

./kcmtp3.f90:6:6: error: Loop iteration variable i is not allowed in THREADPRIVATE.
    do i = 1, 10
       ^
./kcmtp3.f90:8:12: error: A worksharing region may not be closely nested inside a worksharing, explicit task, taskloop, critical, ordered, atomic, or master region
      !$omp  do
             ^^
./kcmtp3.f90:17:6: error: Loop iteration variable i is not allowed in THREADPRIVATE.
    do i = 1, 10
       ^
./kcmtp3.f90:19:12: error: A worksharing region may not be closely nested inside a worksharing, explicit task, taskloop, critical, ordered, atomic, or master region
      !$omp  do
             ^^

and if I uncomment !$omp  threadprivate(j) , I get parse errors. 

and the gfortran error is

kcmtp3.f90:6:14:

    6 |   do i = 1, 10
      |              1
Error: !$OMP DO iteration variable must not be THREADPRIVATE at (1)
kcmtp3.f90:17:14:

   17 |   do i = 1, 10
      |              1
Error: !$OMP DO iteration variable must not be THREADPRIVATE at (1)



Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D92732/new/

https://reviews.llvm.org/D92732



More information about the llvm-commits mailing list