From 1d2f9ac071d436e6be4d693833a3b630e4a7fc15 Mon Sep 17 00:00:00 2001 From: Krish Gupta Date: Wed, 10 Sep 2025 03:41:06 +0530 Subject: [PATCH] [flang][OpenMP] Add lowering test: lastprivate on DO is scoped to wsloop (guards #157035) --- .../Lower/OpenMP/lastprivate-alloc-scope.f90 | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 flang/test/Lower/OpenMP/lastprivate-alloc-scope.f90 diff --git a/flang/test/Lower/OpenMP/lastprivate-alloc-scope.f90 b/flang/test/Lower/OpenMP/lastprivate-alloc-scope.f90 new file mode 100644 index 0000000000000..67d885ed5fb7a --- /dev/null +++ b/flang/test/Lower/OpenMP/lastprivate-alloc-scope.f90 @@ -0,0 +1,22 @@ +! RUN: %flang_fc1 -fopenmp -emit-hlfir %s -o - | FileCheck %s + +program p + type y3; integer, allocatable :: x; end type + type(y3) :: v + integer :: s, n, i + s = 1; n = 10 + allocate(v%x); v%x = 0 +!$omp parallel + if (.not. allocated(v%x)) print *, '101', allocated(v%x) +!$omp do schedule(dynamic) lastprivate(v) + do i = s, n + v%x = i + end do +!$omp end do +!$omp end parallel +end program + +! CHECK: omp.parallel { +! CHECK-NOT: private( +! CHECK: omp.wsloop +! CHECK-SAME: private(