Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion clang/lib/Sema/SemaOpenMP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3321,9 +3321,9 @@ SemaOpenMP::CheckOMPThreadPrivateDecl(SourceLocation Loc,
}
return D;
}

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove this newline

static OMPAllocateDeclAttr::AllocatorTypeTy
getAllocatorKind(Sema &S, DSAStackTy *Stack, Expr *Allocator) {
// No allocator expression → Null mem alloc.
if (!Allocator)
return OMPAllocateDeclAttr::OMPNullMemAlloc;
if (Allocator->isTypeDependent() || Allocator->isValueDependent() ||
Expand All @@ -3337,6 +3337,8 @@ getAllocatorKind(Sema &S, DSAStackTy *Stack, Expr *Allocator) {
for (int I = 0; I < OMPAllocateDeclAttr::OMPUserDefinedMemAlloc; ++I) {
auto AllocatorKind = static_cast<OMPAllocateDeclAttr::AllocatorTypeTy>(I);
const Expr *DefAllocator = Stack->getAllocator(AllocatorKind);
if (!DefAllocator)
continue; // null-guard: predefined not populated
llvm::FoldingSetNodeID DAEId;
DefAllocator->IgnoreImpCasts()->Profile(DAEId, S.getASTContext(),
/*Canonical=*/true);
Expand Down
16 changes: 16 additions & 0 deletions clang/test/OpenMP/allocate-allocator-duplicate.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// RUN: %clang_cc1 -fopenmp -verify %s

typedef enum omp_allocator_handle_t {
omp_default_mem_alloc = 1,
__omp_allocator_handle_t_max__ = __UINTPTR_MAX__
} omp_allocator_handle_t;

void foo(void) {
omp_allocator_handle_t my_handle;
int A[2];
// expected-error@+2 {{'omp_allocator_handle_t' type not found; include <omp.h>}}
// expected-note@+1 {{previous allocator is specified here}}
#pragma omp allocate(A) allocator(my_handle)
// expected-warning@+1 {{allocate directive specifies 'my_handle' allocator while previously used default}}
#pragma omp allocate(A) allocator(my_handle)
}
13 changes: 13 additions & 0 deletions clang/test/OpenMP/allocate-allocator-handle-diag.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// RUN: %clang_cc1 -fopenmp -verify %s
// No <omp.h>; forge a typedef.
typedef enum omp_allocator_handle_t {
omp_default_mem_alloc = 1,
__omp_allocator_handle_t_max__ = __UINTPTR_MAX__
} omp_allocator_handle_t;

void foo(void) {
omp_allocator_handle_t my_handle;
int A[2];
// expected-error@+1 {{'omp_allocator_handle_t' type not found; include <omp.h>}}
#pragma omp allocate(A) allocator(my_handle)
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason why you created 2 tests instead of just one? I think you can just a single test case. Also the naming should be with an _ instead of an -, i.e allocate_allocator_duplicate.c.

22 changes: 22 additions & 0 deletions flang/test/Lower/OpenMP/lastprivate-alloc-scope.f90
Original file line number Diff line number Diff line change
@@ -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(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kparzysz can you please take a look at the f90 test?