diff options
author | Jakub Jelinek <jakub@redhat.com> | 2020-05-30 14:02:56 +0200 |
---|---|---|
committer | Jakub Jelinek <jakub@redhat.com> | 2020-05-30 14:02:56 +0200 |
commit | 05e4db63d044ee235d2fbfab8b0bb9fbdfb18315 (patch) | |
tree | 9fced1a49c8dd58c725d9c8a5bcf98164da2b830 /libgomp/testsuite/libgomp.c-c++-common/alloc-4.c | |
parent | 850533ab160ef40eccfd039e1e3b138cf26e76b8 (diff) | |
download | gcc-05e4db63d044ee235d2fbfab8b0bb9fbdfb18315.zip gcc-05e4db63d044ee235d2fbfab8b0bb9fbdfb18315.tar.gz gcc-05e4db63d044ee235d2fbfab8b0bb9fbdfb18315.tar.bz2 |
openmp: omp_alloc(0, ...) should return NULL.
2020-05-30 Jakub Jelinek <jakub@redhat.com>
* allocator.c (omp_alloc): For size == 0, return NULL early.
* testsuite/libgomp.c-c++-common/alloc-4.c: New test.
Diffstat (limited to 'libgomp/testsuite/libgomp.c-c++-common/alloc-4.c')
-rw-r--r-- | libgomp/testsuite/libgomp.c-c++-common/alloc-4.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/libgomp/testsuite/libgomp.c-c++-common/alloc-4.c b/libgomp/testsuite/libgomp.c-c++-common/alloc-4.c new file mode 100644 index 0000000..841e1bc --- /dev/null +++ b/libgomp/testsuite/libgomp.c-c++-common/alloc-4.c @@ -0,0 +1,25 @@ +#include <omp.h> +#include <stdlib.h> + +const omp_alloctrait_t traits[] += { { omp_atk_pool_size, 1 }, + { omp_atk_fallback, omp_atv_abort_fb } }; + +int +main () +{ + omp_allocator_handle_t a; + + if (omp_alloc (0, omp_null_allocator) != NULL) + abort (); + a = omp_init_allocator (omp_default_mem_space, 2, traits); + if (a != omp_null_allocator) + { + if (omp_alloc (0, a) != NULL + || omp_alloc (0, a) != NULL + || omp_alloc (0, a) != NULL) + abort (); + omp_destroy_allocator (a); + } + return 0; +} |