diff options
author | Tobias Burnus <tburnus@baylibre.com> | 2024-12-03 11:02:03 +0100 |
---|---|---|
committer | Tobias Burnus <tburnus@baylibre.com> | 2024-12-03 11:02:03 +0100 |
commit | 3d72e50caebf232fdd7f70613616ca4fd4fb472b (patch) | |
tree | b60d11e53dc95961e103d8fd33daf22233a12203 /gcc/testsuite/c-c++-common/gomp | |
parent | 83f22c1c526368cafc3d32f03462ecd7847f054f (diff) | |
download | gcc-3d72e50caebf232fdd7f70613616ca4fd4fb472b.zip gcc-3d72e50caebf232fdd7f70613616ca4fd4fb472b.tar.gz gcc-3d72e50caebf232fdd7f70613616ca4fd4fb472b.tar.bz2 |
OpenMP: 'allocate' directive - fixes for 'alignof' and [[omp::decl]]
Fixed a check to permit [[omp::decl(allocate,...)]] parsing in C.
Additionaly, we discussed that 'allocate align' should not affect
'alignof' to avoid issues like with:
int a;
_Alignas(_Alignof(a)) int b;
#pragma omp allocate(a) align(128)
_Alignas(_Alignof(a)) int c;
Thus, the alignment is no longer set in the C and Fortran front ends,
but for static variables now in varpool_node::finalize_decl.
(For stack variables, the alignment is handled in gimplify_bind_expr.)
NOTE: 'omp allocate' is not yet supported in C++.
gcc/c/ChangeLog:
* c-parser.cc (c_parser_omp_allocate): Only check scope if
not in_omp_decl_attribute. Remove setting the alignment.
gcc/ChangeLog:
* cgraphunit.cc (varpool_node::finalize_decl): Set alignment
based on OpenMP's 'omp allocate' attribute/directive.
gcc/fortran/ChangeLog:
* trans-decl.cc (gfc_finish_var_decl): Remove setting the alignment.
libgomp/ChangeLog:
* libgomp.texi (Memory allocation): Mention (non-)effect of 'align'
on _Alignof.
* testsuite/libgomp.c/allocate-7.c: New test.
gcc/testsuite/ChangeLog:
* c-c++-common/gomp/allocate-18.c: Check that alignof is unaffected
by 'omp allocate'.
* c-c++-common/gomp/allocate-19.c: Likewise.
Diffstat (limited to 'gcc/testsuite/c-c++-common/gomp')
-rw-r--r-- | gcc/testsuite/c-c++-common/gomp/allocate-18.c | 6 | ||||
-rw-r--r-- | gcc/testsuite/c-c++-common/gomp/allocate-19.c | 10 |
2 files changed, 8 insertions, 8 deletions
diff --git a/gcc/testsuite/c-c++-common/gomp/allocate-18.c b/gcc/testsuite/c-c++-common/gomp/allocate-18.c index 4182f7e..93c5aca 100644 --- a/gcc/testsuite/c-c++-common/gomp/allocate-18.c +++ b/gcc/testsuite/c-c++-common/gomp/allocate-18.c @@ -17,14 +17,14 @@ typedef enum omp_allocator_handle_t void test0 () { - int A1[5]; + int A1[5], B1[5]; #pragma omp allocate(A1) align(128) allocator(omp_default_mem_alloc) /* { dg-message "sorry, unimplemented: '#pragma omp allocate' not yet supported" "" { target c++ } .-1 } */ #ifndef __cplusplus - _Static_assert (_Alignof(A1) == 128, "wrong alignment"); + _Static_assert (_Alignof(A1) == _Alignof(B1), "wrong alignment"); #elif __cplusplus >= 201103L - static_assert (alignof(A1) == 128, "wrong alignment"); /* { dg-bogus "static assertion failed: wrong alignment" "" { xfail { c++ && { ! c++98_only } } } } */ + static_assert (alignof(A1) == alignof(B1), "wrong alignment"); #endif } diff --git a/gcc/testsuite/c-c++-common/gomp/allocate-19.c b/gcc/testsuite/c-c++-common/gomp/allocate-19.c index ad3493d..5c5fc00 100644 --- a/gcc/testsuite/c-c++-common/gomp/allocate-19.c +++ b/gcc/testsuite/c-c++-common/gomp/allocate-19.c @@ -19,14 +19,14 @@ typedef enum omp_allocator_handle_t __omp_allocator_handle_t_max__ = __UINTPTR_MAX__ } omp_allocator_handle_t; -static int A1[5] = {1,2,3,4,5}; +static int A1[5] = {1,2,3,4,5}, B1[5]; #pragma omp allocate(A1) align(128) allocator(omp_default_mem_alloc) /* { dg-message "sorry, unimplemented: '#pragma omp allocate' not yet supported" "" { target c++ } .-1 } */ #ifndef __cplusplus -_Static_assert (_Alignof(A1) == 128, "wrong alignment"); +_Static_assert (_Alignof(A1) == _Alignof(B1), "wrong alignment"); #elif __cplusplus >= 201103L -static_assert (alignof(A1) == 128, "wrong alignment"); /* { dg-bogus "static assertion failed: wrong alignment" "" { xfail { c++ && { ! c++98_only } } } } */ +static_assert (alignof(A1) == alignof(B1), "wrong alignment"); #endif @@ -49,9 +49,9 @@ get () /* { dg-message "sorry, unimplemented: '#pragma omp allocate' not yet supported" "" { target c++ } .-1 } */ #ifndef __cplusplus - _Static_assert (_Alignof(q) == 1024, "wrong alignment"); + _Static_assert (_Alignof(q) == _Alignof(int), "wrong alignment"); #elif __cplusplus >= 201103L - static_assert (alignof(q) == 1024, "wrong alignment"); /* { dg-bogus "static assertion failed: wrong alignment" "" { xfail { c++ && { ! c++98_only } } } } */ + static_assert (alignof(q) == alignof(int), "wrong alignment"); #endif q += 1; |