
This patch adds support for parsing general lvalues ("locator list item types") for OpenMP "map", "to" and "from" clauses to the C front-end, similar to the previously-posted patch for C++. Such syntax is permitted for OpenMP 5.0 and above. It was previously posted for mainline here: https://gcc.gnu.org/pipermail/gcc-patches/2022-December/609038.html and for the og13 branch here: https://gcc.gnu.org/pipermail/gcc-patches/2023-June/623355.html 2024-01-11 Julian Brown <julian@codesourcery.com> gcc/c-family/ * c-pretty-print.cc (c_pretty_printer::postfix_expression, c_pretty_printer::expression): Add OMP_ARRAY_SECTION support. gcc/c/ * c-parser.cc (c_parser_braced_init, c_parser_conditional_expression): Don't allow OpenMP array section. (c_parser_postfix_expression): Don't allow array section in statement expression. (c_parser_postfix_expression_after_primary): Add support for OpenMP array section parsing. (c_parser_expr_list): Don't allow OpenMP array section here. (c_parser_omp_variable_list): Change ALLOW_DEREF parameter to MAP_LVALUE. Support parsing of general lvalues in "map", "to" and "from" clauses. (c_parser_omp_var_list_parens): Change ALLOW_DEREF parameter to MAP_LVALUE. Update call to c_parser_omp_variable_list. (c_parser_oacc_data_clause): Update calls to c_parser_omp_var_list_parens. (c_parser_omp_clause_reduction): Use OMP_ARRAY_SECTION tree node instead of TREE_LIST for array sections. (c_parser_omp_target): Allow GOMP_MAP_ATTACH. * c-tree.h (c_omp_array_section_p): Add extern declaration. (build_omp_array_section): Add prototype. * c-typeck.cc (c_omp_array_section_p): Add flag. (mark_exp_read): Support OMP_ARRAY_SECTION. (build_omp_array_section): Add function. (build_external_ref): Tweak error path for OpenMP array sections. (handle_omp_array_sections_1): Use OMP_ARRAY_SECTION tree code instead of TREE_LIST. Handle more kinds of expressions. (c_oacc_check_attachments): Use OMP_ARRAY_SECTION instead of TREE_LIST for array sections. (c_finish_omp_clauses): Use OMP_ARRAY_SECTION instead of TREE_LIST. Check for supported expression types. gcc/testsuite/ * gcc.dg/gomp/bad-array-section-c-1.c: New test. * gcc.dg/gomp/bad-array-section-c-2.c: New test. * gcc.dg/gomp/bad-array-section-c-3.c: New test. * gcc.dg/gomp/bad-array-section-c-4.c: New test. * gcc.dg/gomp/bad-array-section-c-5.c: New test. * gcc.dg/gomp/bad-array-section-c-6.c: New test. * gcc.dg/gomp/bad-array-section-c-7.c: New test. * gcc.dg/gomp/bad-array-section-c-8.c: New test. libgomp/ * libgomp.texi: C/C++ lvalues are supported now for map/to/from. * testsuite/libgomp.c-c++-common/ind-base-4.c: New test. * testsuite/libgomp.c-c++-common/unary-ptr-1.c: New test.
50 lines
855 B
C
50 lines
855 B
C
// { dg-do run }
|
|
// { dg-options "-fopenmp" }
|
|
|
|
#include <assert.h>
|
|
#include <stdlib.h>
|
|
|
|
typedef struct
|
|
{
|
|
int x[10];
|
|
} S;
|
|
|
|
typedef struct
|
|
{
|
|
S ***s;
|
|
} T;
|
|
|
|
typedef struct
|
|
{
|
|
T **t;
|
|
} U;
|
|
|
|
void
|
|
foo (void)
|
|
{
|
|
U *u = (U *) malloc (sizeof (U));
|
|
T *real_t = (T *) malloc (sizeof (T));
|
|
S *real_s = (S *) malloc (sizeof (S));
|
|
T **t_pp = &real_t;
|
|
S **s_pp = &real_s;
|
|
S ***s_ppp = &s_pp;
|
|
u->t = t_pp;
|
|
(*u->t)->s = s_ppp;
|
|
for (int i = 0; i < 10; i++)
|
|
(**((*u->t)->s))->x[i] = 0;
|
|
#pragma omp target map(u->t, *u->t, (*u->t)->s, *(*u->t)->s, **(*u->t)->s, \
|
|
(**(*u->t)->s)->x[0:10])
|
|
for (int i = 0; i < 10; i++)
|
|
(**((*u->t)->s))->x[i] = i * 3;
|
|
for (int i = 0; i < 10; i++)
|
|
assert ((**((*u->t)->s))->x[i] == i * 3);
|
|
free (real_s);
|
|
free (real_t);
|
|
free (u);
|
|
}
|
|
|
|
int main (int argc, char *argv[])
|
|
{
|
|
foo ();
|
|
return 0;
|
|
}
|