[flang-commits] [flang] 956a84d - [flang] [OpenMP 4.5] Adding lit test cases for OpenMP Constructs.

David Truby via flang-commits flang-commits at lists.llvm.org
Thu Sep 24 05:09:39 PDT 2020


Author: Praveen G
Date: 2020-09-24T13:09:20+01:00
New Revision: 956a84da0616eb761297b46aa65750d738fb1544

URL: https://github.com/llvm/llvm-project/commit/956a84da0616eb761297b46aa65750d738fb1544
DIFF: https://github.com/llvm/llvm-project/commit/956a84da0616eb761297b46aa65750d738fb1544.diff

LOG:     [flang] [OpenMP 4.5] Adding lit test cases for OpenMP Constructs.

 1. Section 2.5   : Parallel Construct
 2. Section 2.7.1 : Loop Construct
 3. Section 2.7.2 : Sections Construct
 4. Section 2.7.3 : Single Construct
 5. Section 2.7.4 : Workshare Construct
 6. Section 2.8.1 : Simd Construct
 7. Section 2.8.3 : Loop Simd Construct
 8. Section 2.9.1 : Task Construct
 9. Section 2.9.2 : Taskloop Construct
10. Section 2.9.3 : Taskloop Simd Construct

Most of the test cases added as part of this change contains semantic errors except few cases which are semantically correct but thrown a semantic error.

Currently flang is not throwing the errors for these cases and throwing semantic errors for the following correct test cases

{omp-do03.f90 , omp-loop-simd01.f90 , omp-simd02.f90 , omp-taskloop01.f90}

Hence, all the test cases are marked as XFAIL.

Reviewed By: DavidTruby

Differential Revision: https://reviews.llvm.org/D87908

Added: 
    flang/test/Semantics/omp-do01.f90
    flang/test/Semantics/omp-do02.f90
    flang/test/Semantics/omp-do03.f90
    flang/test/Semantics/omp-do04.f90
    flang/test/Semantics/omp-do05.f90
    flang/test/Semantics/omp-do06.f90
    flang/test/Semantics/omp-do07.f90
    flang/test/Semantics/omp-do08.f90
    flang/test/Semantics/omp-do09.f90
    flang/test/Semantics/omp-do10.f90
    flang/test/Semantics/omp-loop-simd01.f90
    flang/test/Semantics/omp-parallell01.f90
    flang/test/Semantics/omp-parallell02.f90
    flang/test/Semantics/omp-sections01.f90
    flang/test/Semantics/omp-simd01.f90
    flang/test/Semantics/omp-simd02.f90
    flang/test/Semantics/omp-simd03.f90
    flang/test/Semantics/omp-single01.f90
    flang/test/Semantics/omp-single02.f90
    flang/test/Semantics/omp-task01.f90
    flang/test/Semantics/omp-taskloop-simd01.f90
    flang/test/Semantics/omp-taskloop01.f90
    flang/test/Semantics/omp-taskloop02.f90
    flang/test/Semantics/omp-taskloop03.f90
    flang/test/Semantics/omp-workshare01.f90
    flang/test/Semantics/omp-workshare02.f90

Modified: 
    

Removed: 
    


################################################################################
diff  --git a/flang/test/Semantics/omp-do01.f90 b/flang/test/Semantics/omp-do01.f90
new file mode 100644
index 000000000000..d87d60254fd2
--- /dev/null
+++ b/flang/test/Semantics/omp-do01.f90
@@ -0,0 +1,18 @@
+! RUN: %S/test_errors.sh %s %t %f18 -fopenmp
+! XFAIL: *
+
+! OpenMP Version 4.5
+! 2.7.1 Loop Construct
+! collapse(n) where n > num of loops
+
+program omp_do
+  integer i, j, k
+
+  !ERROR: Not enough do loops for collapsed !$OMP DO
+  !$omp do collapse(2)
+  do i = 1, 10
+    print *, "hello"
+  end do
+  !$omp end do
+
+end program omp_do

diff  --git a/flang/test/Semantics/omp-do02.f90 b/flang/test/Semantics/omp-do02.f90
new file mode 100644
index 000000000000..dd654d9ed021
--- /dev/null
+++ b/flang/test/Semantics/omp-do02.f90
@@ -0,0 +1,21 @@
+! RUN: %S/test_errors.sh %s %t %f18 -fopenmp
+! XFAIL: *
+
+! OpenMP Version 4.5
+! 2.7.1 Loop Construct
+! Exit statement terminating !$OMP DO loop
+
+program omp_do
+  integer i, j, k
+
+  !$omp do
+  do i = 1, 10
+    do j = 1, 10
+      print *, "Hello"
+    end do
+    !ERROR: EXIT statement terminating !$OMP DO loop
+    exit
+  end do
+  !$omp end do
+
+end program omp_do

diff  --git a/flang/test/Semantics/omp-do03.f90 b/flang/test/Semantics/omp-do03.f90
new file mode 100644
index 000000000000..e60a2ed3c337
--- /dev/null
+++ b/flang/test/Semantics/omp-do03.f90
@@ -0,0 +1,26 @@
+! RUN: %S/test_errors.sh %s %t %f18 -fopenmp
+! XFAIL: *
+
+! OpenMP Version 4.5
+! 2.7.1 Loop Construct
+! Semantic error for correct test case
+
+program omp_do
+  integer i, j, k
+  integer :: a(10), b(10)
+  a = 10
+  j = 0
+
+  !$omp parallel
+    !$omp do linear(j:1)
+    do i = 1, 10
+      j = j + 1
+      b(i) = a(i) * 2.0
+    end do
+    !$omp end do
+  !$omp end parallel
+
+  print *, j
+  print *, b
+
+end program omp_do

diff  --git a/flang/test/Semantics/omp-do04.f90 b/flang/test/Semantics/omp-do04.f90
new file mode 100644
index 000000000000..69b3dd573762
--- /dev/null
+++ b/flang/test/Semantics/omp-do04.f90
@@ -0,0 +1,20 @@
+! RUN: %S/test_errors.sh %s %t %f18 -fopenmp
+! XFAIL: *
+
+! OpenMP Version 4.5
+! 2.7.1 Loop Construct
+! The loop iteration variable may not appear in a threadprivate directive.
+
+program omp_do
+  integer i, j, k
+
+  !$omp do firstprivate(i)
+  !ERROR: !$OMP DO iteration variable i is not allowed in threadprivate
+  do i = 1, 10
+    do j = 1, 10
+      print *, "Hello"
+    end do
+  end do
+  !$omp end do
+
+end program omp_do

diff  --git a/flang/test/Semantics/omp-do05.f90 b/flang/test/Semantics/omp-do05.f90
new file mode 100644
index 000000000000..8722e50a64f7
--- /dev/null
+++ b/flang/test/Semantics/omp-do05.f90
@@ -0,0 +1,26 @@
+! RUN: %S/test_errors.sh %s %t %f18 -fopenmp
+! XFAIL: *
+
+! OpenMP Version 4.5
+! 2.7.1 Loop Construct
+! chunk_size must be a loop invariant integer expression
+! with a positive value.
+
+program omp_do
+  integer i, j, k
+  integer :: a(10), b(10)
+  a = 10
+  j = 0
+
+  !ERROR: INTEGER expression of SCHEDULE clause chunk_size must be positive
+  !$omp do schedule(static, -1)
+  do i = 1, 10
+    j = j + 1
+    b(i) = a(i) * 2.0
+  end do
+  !$omp end do
+
+  print *, j
+  print *, b
+
+end program omp_do

diff  --git a/flang/test/Semantics/omp-do06.f90 b/flang/test/Semantics/omp-do06.f90
new file mode 100644
index 000000000000..c00af5cdf7ae
--- /dev/null
+++ b/flang/test/Semantics/omp-do06.f90
@@ -0,0 +1,21 @@
+! RUN: %S/test_errors.sh %s %t %f18 -fopenmp
+! XFAIL:*
+
+! OpenMP Version 4.5
+! 2.7.1 Loop Construct
+! The ordered clause must be present on the loop construct if any ordered
+! region ever binds to a loop region arising from the loop construct.
+
+program omp_do
+  integer i, j, k
+
+  !$omp do
+  do i = 1, 10
+    !ERROR: ‘ordered’ region inside a loop region without an ordered clause.
+    !$omp ordered
+    call my_func()
+    !$omp end ordered
+  end do
+  !$omp end do
+
+end program omp_do

diff  --git a/flang/test/Semantics/omp-do07.f90 b/flang/test/Semantics/omp-do07.f90
new file mode 100644
index 000000000000..670e3cf4e08b
--- /dev/null
+++ b/flang/test/Semantics/omp-do07.f90
@@ -0,0 +1,24 @@
+! RUN: %S/test_errors.sh %s %t %f18 -fopenmp
+! XFAIL:*
+
+! OpenMP Version 4.5
+! 2.7.1 Loop Construct
+! No statement in the associated loops other than the DO statements
+! can cause a branch out of the loops
+
+program omp_do
+  integer i, j, k
+
+  !$omp do
+  do i = 1, 10
+    do j = 1, 10
+      print *, "Hello"
+      !ERROR: invalid branch to/from OpenMP structured block
+      goto 10
+    end do
+  end do
+  !$omp end do
+
+  10 stop
+
+end program omp_do

diff  --git a/flang/test/Semantics/omp-do08.f90 b/flang/test/Semantics/omp-do08.f90
new file mode 100644
index 000000000000..9f8b551e8b06
--- /dev/null
+++ b/flang/test/Semantics/omp-do08.f90
@@ -0,0 +1,19 @@
+! RUN: %S/test_errors.sh %s %t %f18 -fopenmp
+! XFAIL: *
+
+! OpenMP Version 4.5
+! 2.7.1 Loop Construct
+
+program omp_do
+  integer i, j, k
+  !$omp do collapse(2)
+  do i = 1, 10
+    !ERROR: CYCLE statement to non-innermost collapsed !$OMP DO loop
+    if (i .lt. 5) cycle
+    do j = 1, 10
+      print *, "Hello"
+    end do
+  end do
+  !$omp end do
+
+end program omp_do

diff  --git a/flang/test/Semantics/omp-do09.f90 b/flang/test/Semantics/omp-do09.f90
new file mode 100644
index 000000000000..1c8a6eefd334
--- /dev/null
+++ b/flang/test/Semantics/omp-do09.f90
@@ -0,0 +1,22 @@
+! RUN: %S/test_errors.sh %s %t %f18 -fopenmp
+! XFAIL: *
+
+! OpenMP Version 4.5
+! 2.7.1 Loop Construct
+! The do-loop cannot be a DO WHILE or a DO loop without loop control.
+
+program omp_do
+  integer i, j, k
+  i = 0
+
+  !$omp do
+  !ERROR: !$OMP DO cannot be a DO WHILE or DO without loop control
+  do while (i .lt. 10)
+    do j = 1, 10
+      print *, "Hello"
+    end do
+    i = i + 1
+  end do
+  !$omp end do
+
+end program omp_do

diff  --git a/flang/test/Semantics/omp-do10.f90 b/flang/test/Semantics/omp-do10.f90
new file mode 100644
index 000000000000..c56887a20d74
--- /dev/null
+++ b/flang/test/Semantics/omp-do10.f90
@@ -0,0 +1,20 @@
+! RUN: %S/test_errors.sh %s %t %f18 -fopenmp
+! XFAIL: *
+
+! OpenMP Version 4.5
+! 2.7.1 Loop Construct
+! The do-loop iteration variable must be of type integer.
+
+program omp_do
+  real i, j, k
+
+  !$omp do
+  !ERROR: The do-loop iteration variable must be of type integer.
+  do i = 1, 10
+    do j = 1, 10
+      print *, "Hello"
+    end do
+  end do
+  !$omp end do
+
+end program omp_do

diff  --git a/flang/test/Semantics/omp-loop-simd01.f90 b/flang/test/Semantics/omp-loop-simd01.f90
new file mode 100644
index 000000000000..9d2596f6d95e
--- /dev/null
+++ b/flang/test/Semantics/omp-loop-simd01.f90
@@ -0,0 +1,24 @@
+! RUN: %S/test_errors.sh %s %t %f18 -fopenmp
+! XFAIL: *
+
+! OpenMP Version 4.5
+! 2.8.3 Loop simd Construct
+! Semantic error for correct test case.
+
+program omp_loop_simd
+  integer i, j, k, l
+  k = 0;
+  l = 0
+
+  !$omp parallel do simd linear(l)
+  do i = 1, 10
+    do j = 1, 10
+      print *, "omp loop simd"
+      k = k + 1
+      l = l + 1
+    end do
+  end do
+
+  print *, k, l
+
+end program omp_loop_simd

diff  --git a/flang/test/Semantics/omp-parallell01.f90 b/flang/test/Semantics/omp-parallell01.f90
new file mode 100644
index 000000000000..e3490563f332
--- /dev/null
+++ b/flang/test/Semantics/omp-parallell01.f90
@@ -0,0 +1,24 @@
+! RUN: %S/test_errors.sh %s %t %f18 -fopenmp
+! XFAIL: *
+
+! OpenMP Version 4.5
+! 2.5 parallel construct.
+! A program that branches into or out of a parallel region
+! is non-conforming.
+
+program omp_parallel
+  integer i, j, k
+
+  !$omp parallel
+  do i = 1, 10
+    do j = 1, 10
+      print *, "Hello"
+      !ERROR: invalid branch to/from OpenMP structured block
+      goto 10
+    end do
+  end do
+  !$omp end parallel
+
+  10 stop
+
+end program omp_parallel

diff  --git a/flang/test/Semantics/omp-parallell02.f90 b/flang/test/Semantics/omp-parallell02.f90
new file mode 100644
index 000000000000..3152d5de0714
--- /dev/null
+++ b/flang/test/Semantics/omp-parallell02.f90
@@ -0,0 +1,24 @@
+! RUN: %S/test_errors.sh %s %t %f18 -fopenmp
+! XFAIL: *
+
+! OpenMP Version 4.5
+! 2.5 parallel construct.
+! A program that branches into or out of a parallel region
+! is non-conforming.
+
+program omp_parallel
+  integer i, j, k
+
+  !ERROR: invalid entry to OpenMP structured block
+  goto 10
+
+  !$omp parallel
+  do i = 1, 10
+    do j = 1, 10
+      print *, "Hello"
+      10 stop
+    end do
+  end do
+  !$omp end parallel
+
+end program omp_parallel

diff  --git a/flang/test/Semantics/omp-sections01.f90 b/flang/test/Semantics/omp-sections01.f90
new file mode 100644
index 000000000000..7bf9d0ae0161
--- /dev/null
+++ b/flang/test/Semantics/omp-sections01.f90
@@ -0,0 +1,16 @@
+! RUN: %S/test_errors.sh %s %t %f18 -fopenmp
+! XFAIL: *
+
+! OpenMP Version 4.5
+! 2.7.2 sections Construct
+! Only a single nowait clause can appear on a sections directive.
+
+program omp_sections
+
+  !$omp sections
+    !$omp section
+    print *, "omp section"
+  !ERROR: Only a single nowait clause can appear on a sections directive.
+  !$omp end sections nowait nowait
+
+end program omp_sections

diff  --git a/flang/test/Semantics/omp-simd01.f90 b/flang/test/Semantics/omp-simd01.f90
new file mode 100644
index 000000000000..52e3951bb8bb
--- /dev/null
+++ b/flang/test/Semantics/omp-simd01.f90
@@ -0,0 +1,23 @@
+! RUN: %S/test_errors.sh %s %t %f18 -fopenmp
+! XFAIL: *
+
+! OpenMP Version 4.5
+! 2.8.1 simd Construct
+! A program that branches into or out of a simd region is non-conforming.
+
+program omp_simd
+  integer i, j
+
+  !$omp simd
+  do i = 1, 10
+    do j = 1, 10
+      print *, "omp simd"
+      !ERROR: invalid branch to/from OpenMP structured block
+      goto 10
+    end do
+  end do
+  !$omp end simd
+
+  10 stop
+
+end program omp_simd

diff  --git a/flang/test/Semantics/omp-simd02.f90 b/flang/test/Semantics/omp-simd02.f90
new file mode 100644
index 000000000000..5665d31a6fba
--- /dev/null
+++ b/flang/test/Semantics/omp-simd02.f90
@@ -0,0 +1,22 @@
+! RUN: %S/test_errors.sh %s %t %f18 -fopenmp
+! XFAIL: *
+
+! OpenMP Version 4.5
+! 2.8.1 simd Construct
+! Semantic error for correct test case
+
+program omp_simd
+  integer i, j, k
+  integer, allocatable :: a(:)
+
+  allocate(a(10))
+
+  !$omp simd aligned(a)
+  do i = 1, 10
+    a(i) = i
+  end do
+  !$omp end simd
+
+  print *, a
+
+end program omp_simd

diff  --git a/flang/test/Semantics/omp-simd03.f90 b/flang/test/Semantics/omp-simd03.f90
new file mode 100644
index 000000000000..1bde68d97409
--- /dev/null
+++ b/flang/test/Semantics/omp-simd03.f90
@@ -0,0 +1,26 @@
+! RUN: %S/test_errors.sh %s %t %f18 -fopenmp
+! XFAIL: *
+
+! OpenMP Version 4.5
+! 2.8.1 simd Construct
+! An ordered construct with the simd clause is the only OpenMP construct
+! that can be encountered during execution of a simd region.
+
+program omp_simd
+  integer i, j, k
+  integer, allocatable :: a(:)
+
+  allocate(a(10))
+
+  !$omp simd
+  do i = 1, 10
+    !ERROR: Invalid OpenMP construct inside simd region
+    !$omp single
+    a(i) = i
+    !$omp end single
+  end do
+  !$omp end simd
+
+  print *, a
+
+end program omp_simd

diff  --git a/flang/test/Semantics/omp-single01.f90 b/flang/test/Semantics/omp-single01.f90
new file mode 100644
index 000000000000..527a6d005d2f
--- /dev/null
+++ b/flang/test/Semantics/omp-single01.f90
@@ -0,0 +1,17 @@
+! RUN: %S/test_errors.sh %s %t %f18 -fopenmp
+! XFAIL: *
+
+! OpenMP Version 4.5
+! 2.7.3 single Construct
+! Symbol present on multiple clauses
+
+program omp_single
+  integer i
+  i = 10
+
+  !$omp single private(i)
+  print *, "omp single", i
+  !ERROR: Symbol ‘i’ present on multiple clauses
+  !$omp end single copyprivate(i)
+
+end program omp_single

diff  --git a/flang/test/Semantics/omp-single02.f90 b/flang/test/Semantics/omp-single02.f90
new file mode 100644
index 000000000000..0f68f26d2c27
--- /dev/null
+++ b/flang/test/Semantics/omp-single02.f90
@@ -0,0 +1,19 @@
+! RUN: %S/test_errors.sh %s %t %f18 -fopenmp
+! XFAIL: *
+
+! OpenMP Version 4.5
+! 2.7.3 single Construct
+! Copyprivate variable is not thread private or private in outer context
+
+program omp_single
+  integer i
+  i = 10
+
+  !$omp parallel
+    !$omp single
+    print *, "omp single", i
+    !ERROR: copyprivate variable ‘i’ is not threadprivate or private
+    !$omp end single copyprivate(i)
+  !$omp end parallel
+
+end program omp_single

diff  --git a/flang/test/Semantics/omp-task01.f90 b/flang/test/Semantics/omp-task01.f90
new file mode 100644
index 000000000000..790ca15f9f81
--- /dev/null
+++ b/flang/test/Semantics/omp-task01.f90
@@ -0,0 +1,32 @@
+! RUN: %S/test_errors.sh %s %t %f18 -fopenmp
+! XFAIL: *
+
+! OpenMP Version 4.5
+! 2.9.1 task Construct
+! Invalid entry to OpenMP structured block.
+
+recursive subroutine traverse ( P )
+  type Node
+    type(Node), pointer :: left, right
+  end type Node
+
+  type(Node) :: P
+
+  !ERROR: invalid entry to OpenMP structured block
+  goto 10
+
+  if (associated(P%left)) then
+    !$omp task
+    call traverse(P%left)
+    10 stop
+    !$omp end task
+  endif
+
+  if (associated(P%right)) then
+    !$omp task
+    call traverse(P%right)
+    !$omp end task
+    endif
+  call process ( P )
+
+ end subroutine traverse

diff  --git a/flang/test/Semantics/omp-taskloop-simd01.f90 b/flang/test/Semantics/omp-taskloop-simd01.f90
new file mode 100644
index 000000000000..8d02c32ab3ad
--- /dev/null
+++ b/flang/test/Semantics/omp-taskloop-simd01.f90
@@ -0,0 +1,21 @@
+! RUN: %S/test_errors.sh %s %t %f18 -fopenmp
+! XFAIL: *
+
+! OpenMP Version 4.5
+! 2.9.3 taskloop simd Construct
+! No reduction clause may be specified for !$omp taskloop simd.
+
+program omp_taskloop_simd
+  integer i , j , k
+
+  !ERROR: Unexpected clause specified for !$OMP taskloop simd
+  !$omp taskloop simd reduction(+:k)
+  do i=1,10000
+    do j=1,i
+      call loop_body(i, j)
+      k = k + 1
+    end do
+  end do
+  !$omp end taskloop simd
+
+end program omp_taskloop_simd

diff  --git a/flang/test/Semantics/omp-taskloop01.f90 b/flang/test/Semantics/omp-taskloop01.f90
new file mode 100644
index 000000000000..2b373d416d77
--- /dev/null
+++ b/flang/test/Semantics/omp-taskloop01.f90
@@ -0,0 +1,26 @@
+! RUN: %S/test_errors.sh %s %t %f18 -fopenmp
+! XFAIL: *
+
+! OpenMP Version 4.5
+! 2.9.2 taskloop Construct
+! Assert fail for correct test case.
+
+subroutine parallel_work
+  integer i
+  integer j
+
+  !$omp taskgroup
+    !$omp task
+    call long_running_task()
+    !$omp end task
+
+    !$omp taskloop private(j) grainsize(500) nogroup
+    do i=1,10000
+      do j=1,i
+        call loop_body(i, j)
+      end do
+    end do
+    !$omp end taskloop
+  !$omp end taskgroup
+
+end subroutine parallel_work

diff  --git a/flang/test/Semantics/omp-taskloop02.f90 b/flang/test/Semantics/omp-taskloop02.f90
new file mode 100644
index 000000000000..147cb2a8e87c
--- /dev/null
+++ b/flang/test/Semantics/omp-taskloop02.f90
@@ -0,0 +1,22 @@
+! RUN: %S/test_errors.sh %s %t %f18 -fopenmp
+! XFAIL: *
+
+! OpenMP Version 4.5
+! 2.9.2 taskloop Construct
+! Invalid entry to OpenMP structured block.
+
+program omp_taskloop
+  integer i , j
+
+  !ERROR: invalid entry to OpenMP structured block
+  goto 10
+
+  !$omp taskloop private(j) grainsize(500) nogroup
+  do i=1,10000
+    do j=1,i
+      10 call loop_body(i, j)
+    end do
+  end do
+  !$omp end taskloop
+
+end program omp_taskloop

diff  --git a/flang/test/Semantics/omp-taskloop03.f90 b/flang/test/Semantics/omp-taskloop03.f90
new file mode 100644
index 000000000000..7b8f7ca54dd5
--- /dev/null
+++ b/flang/test/Semantics/omp-taskloop03.f90
@@ -0,0 +1,25 @@
+! RUN: %S/test_errors.sh %s %t %f18 -fopenmp
+! XFAIL: *
+
+! OpenMP Version 4.5
+! 2.9.2 taskloop Construct
+! All loops associated with the taskloop construct must be perfectly nested,
+! there must be no intervening code or any OpenMP directive between
+! any two loops
+
+program omp_taskloop
+  integer i, j
+
+  !$omp taskloop private(j) grainsize(500) nogroup
+  do i=1, 10000
+    do j=1, i
+      call loop_body(i, j)
+    end do
+    !ERROR: Loops associated with !$omp taskloop is not perfectly nested
+    !$omp single
+    print *, "omp single"
+    !$omp end single
+  end do
+  !$omp end taskloop
+
+end program omp_taskloop

diff  --git a/flang/test/Semantics/omp-workshare01.f90 b/flang/test/Semantics/omp-workshare01.f90
new file mode 100644
index 000000000000..032c2db217f9
--- /dev/null
+++ b/flang/test/Semantics/omp-workshare01.f90
@@ -0,0 +1,23 @@
+! RUN: %S/test_errors.sh %s %t %f18 -fopenmp
+! XFAIL: *
+
+! OpenMP Version 4.5
+! 2.7.4 workshare Construct
+! Invalid do construct inside !$omp workshare
+
+subroutine workshare(aa, bb, cc, dd, ee, ff, n)
+  integer n, i
+  real aa(n,n), bb(n,n), cc(n,n), dd(n,n), ee(n,n), ff(n,n)
+
+  !$omp workshare
+  !ERROR: Unexpected do stmt inside !$omp workshare
+  do i = 1, n
+    print *, "omp workshare"
+  end do
+
+  aa = bb
+  cc = dd
+  ee = ff
+  !$omp end workshare
+
+end subroutine workshare

diff  --git a/flang/test/Semantics/omp-workshare02.f90 b/flang/test/Semantics/omp-workshare02.f90
new file mode 100644
index 000000000000..f56d55cb6791
--- /dev/null
+++ b/flang/test/Semantics/omp-workshare02.f90
@@ -0,0 +1,29 @@
+! RUN: %S/test_errors.sh %s %t %f18 -fopenmp
+! XFAIL: *
+
+! OpenMP Version 4.5
+! 2.7.4 workshare Construct
+! The !omp workshare construct must not contain any user defined
+! function calls unless the function is ELEMENTAL.
+
+module my_mod
+  contains
+  function my_func(n)
+    integer :: my_func(n, n)
+    my_func = 10
+  end function my_func
+end module my_mod
+
+subroutine workshare(aa, bb, cc, dd, ee, ff, n)
+  use my_mod
+  integer n, i
+  real aa(n,n), bb(n,n), cc(n,n), dd(n,n), ee(n,n), ff(n,n)
+
+  !$omp workshare
+  !ERROR: Non-ELEMENTAL function is not allowed in !$omp workshare construct
+  aa = my_func(n)
+  cc = dd
+  ee = ff
+  !$omp end workshare
+
+end subroutine workshare


        


More information about the flang-commits mailing list