-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[clang][OpenMP] Diagnose invalid allocator in #pragma omp allocate
; avoid null deref
#158146
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
1d2f9ac
21c0511
9b092d7
f2397d1
788e6f7
b09fab1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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) | ||
} |
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) | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
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( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @kparzysz can you please take a look at the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove this newline