summaryrefslogtreecommitdiffstats
path: root/clang/test/OpenMP/nvptx_allocate_messages.cpp
diff options
context:
space:
mode:
authorAlexey Bataev <a.bataev@hotmail.com>2019-03-22 15:25:12 +0000
committerAlexey Bataev <a.bataev@hotmail.com>2019-03-22 15:25:12 +0000
commit318f431beb1898a75d12701871c23785283cfd75 (patch)
tree55c81fcb1c10f11fa2818d9e81ecb4c98e2be095 /clang/test/OpenMP/nvptx_allocate_messages.cpp
parent6f0191a55a53a2ac337914d670fe3f127ac65b70 (diff)
downloadbcm5719-llvm-318f431beb1898a75d12701871c23785283cfd75.tar.gz
bcm5719-llvm-318f431beb1898a75d12701871c23785283cfd75.zip
[OPENMP]Allow no allocator clause in target regions with requires
dynamic_allocators. According to the OpenMP 5.0, 2.11.3 allocate Directive, Restrictions, allocate directives that appear in a target region must specify an allocator clause unless a requires directive with the dynamic_allocators clause is present in the same compilation unit. Patch adds a check for a presence of the requires directive with the dynamic_allocators clause. llvm-svn: 356758
Diffstat (limited to 'clang/test/OpenMP/nvptx_allocate_messages.cpp')
-rw-r--r--clang/test/OpenMP/nvptx_allocate_messages.cpp19
1 files changed, 12 insertions, 7 deletions
diff --git a/clang/test/OpenMP/nvptx_allocate_messages.cpp b/clang/test/OpenMP/nvptx_allocate_messages.cpp
index 99aef4338d8..5bb94222270 100644
--- a/clang/test/OpenMP/nvptx_allocate_messages.cpp
+++ b/clang/test/OpenMP/nvptx_allocate_messages.cpp
@@ -1,17 +1,22 @@
// RUN: %clang_cc1 -verify -fopenmp -triple x86_64-apple-darwin10.6.0 -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm-bc -o %t-host.bc %s
// RUN: %clang_cc1 -verify -DDEVICE -fopenmp -triple nvptx64-nvidia-cuda -fopenmp-targets=nvptx64-nvidia-cuda -fsyntax-only %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-host.bc
-#ifndef DEVICE
+// RUN: %clang_cc1 -verify -DDEVICE -DREQUIRES -fopenmp -triple nvptx64-nvidia-cuda -fopenmp-targets=nvptx64-nvidia-cuda -fsyntax-only %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-host.bc
+#if !defined(DEVICE) || defined(REQUIRES)
// expected-no-diagnostics
#endif // DEVICE
#ifndef HEADER
#define HEADER
+#if defined(REQUIRES) && defined(DEVICE)
+#pragma omp requires dynamic_allocators
+#endif // REQUIRES && DEVICE
+
int bar() {
int res = 0;
-#ifdef DEVICE
+#if defined(DEVICE) && !defined(REQUIRES)
// expected-error@+2 {{expected an 'allocator' clause inside of the target region; provide an 'allocator' clause or use 'requires' directive with the 'dynamic_allocators' clause}}
-#endif // DEVICE
+#endif // DEVICE && !REQUIRES
#pragma omp allocate(res)
return 0;
}
@@ -65,13 +70,13 @@ int main () {
#pragma omp allocate(a) allocator(omp_thread_mem_alloc)
a=2;
double b = 3;
-#ifdef DEVICE
+#if defined(DEVICE) && !defined(REQUIRES)
// expected-error@+2 {{expected an 'allocator' clause inside of the target region; provide an 'allocator' clause or use 'requires' directive with the 'dynamic_allocators' clause}}
-#endif // DEVICE
+#endif // DEVICE && !REQUIRES
#pragma omp allocate(b)
-#ifdef DEVICE
+#if defined(DEVICE) && !defined(REQUIRES)
// expected-note@+2 {{called by 'main'}}
-#endif // DEVICE
+#endif // DEVICE && !REQUIRES
return (foo<int>() + bar());
}
OpenPOWER on IntegriCloud