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/c/c-parser.cc | |
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/c/c-parser.cc')
-rw-r--r-- | gcc/c/c-parser.cc | 5 |
1 files changed, 1 insertions, 4 deletions
diff --git a/gcc/c/c-parser.cc b/gcc/c/c-parser.cc index 0acba05..a7719ac 100644 --- a/gcc/c/c-parser.cc +++ b/gcc/c/c-parser.cc @@ -22158,7 +22158,7 @@ c_parser_omp_allocate (c_parser *parser) "%<allocate%> directive", var); continue; } - if (!c_check_in_current_scope (var)) + if (!parser->in_omp_decl_attribute && !c_check_in_current_scope (var)) { error_at (OMP_CLAUSE_LOCATION (nl), "%<allocate%> directive must be in the same scope as %qD", @@ -22199,9 +22199,6 @@ c_parser_omp_allocate (c_parser *parser) = {EXPR_LOC_OR_LOC (allocator, OMP_CLAUSE_LOCATION (nl)), var}; walk_tree (&allocator, c_check_omp_allocate_allocator_r, &data, NULL); } - if (alignment) - SET_DECL_ALIGN (var, BITS_PER_UNIT * MAX (tree_to_uhwi (alignment), - DECL_ALIGN_UNIT (var))); DECL_ATTRIBUTES (var) = tree_cons (get_identifier ("omp allocate"), build_tree_list (allocator, alignment), DECL_ATTRIBUTES (var)); |