]> git.ipfire.org Git - thirdparty/gcc.git/commit
OpenMP: lvalue parsing for map/to/from clauses (C++)
authorJulian Brown <julian@codesourcery.com>
Mon, 12 Sep 2022 17:11:29 +0000 (17:11 +0000)
committerJulian Brown <julian@codesourcery.com>
Tue, 9 Jan 2024 10:08:18 +0000 (10:08 +0000)
commit1413af02d62182bc1e19698aaa4dae406f8f13bf
tree14a9d0040741dbed9b1e19888357f7c6cda32589
parent8f80b9f0904eb98b41913068ce7dc021c2f35ecc
OpenMP: lvalue parsing for map/to/from clauses (C++)

This patch supports "lvalue" parsing (or "locator list item type" parsing)
for several OpenMP clause types for C++, as required for OpenMP 5.0
and above.

This version has been rebased -- some things have changed around
template handling recently, e.g. removal of build_non_dependent_expr and
tsubst_copy.  A new potential corner-case issue has shown up regarding
implicit mapping of references to pointer to pointers -- an interaction
with the post-review fixes/rework for the patch here:

  https://gcc.gnu.org/pipermail/gcc-patches/2023-November/638602.html

Which fixed the (new) tests baseptrs-[6789].C.  I've noted that for now in
the patch, and adjusted the baseptrs-[46].C tests slightly to accommodate.

2024-01-08  Julian Brown  <julian@codesourcery.com>

gcc/c-family/
* c-common.h (c_omp_address_inspector): Remove static from get_origin
and maybe_unconvert_ref methods.
* c-omp.cc (c_omp_split_clauses): Support OMP_ARRAY_SECTION.
(c_omp_address_inspector::map_supported_p): Handle OMP_ARRAY_SECTION.
(c_omp_address_inspector::get_origin): Avoid dereferencing possibly
NULL type when processing template decls.
(c_omp_address_inspector::maybe_unconvert_ref): Likewise.

gcc/cp/
* constexpr.cc (potential_consant_expression_1): Handle
OMP_ARRAY_SECTION.
* cp-tree.h (grok_omp_array_section, build_omp_array_section): Add
prototypes.
* decl2.cc (grok_omp_array_section): New function.
* error.cc (dump_expr): Handle OMP_ARRAY_SECTION.
* parser.cc (cp_parser_new): Initialize parser->omp_array_section_p.
(cp_parser_statement_expr): Disallow array sections.
(cp_parser_postfix_open_square_expression): Support OMP_ARRAY_SECTION
parsing.
(cp_parser_parenthesized_expression_list, cp_parser_lambda_expression,
cp_parser_braced_list): Disallow array sections.
(cp_parser_omp_var_list_no_open): Remove ALLOW_DEREF parameter, add
MAP_LVALUE in its place.  Support generalised lvalue parsing for
OpenMP map, to and from clauses.  Use OMP_ARRAY_SECTION
code instead of TREE_LIST to represent OpenMP array sections.
(cp_parser_omp_var_list): Remove ALLOW_DEREF parameter, add MAP_LVALUE.
Pass to cp_parser_omp_var_list_no_open.
(cp_parser_oacc_data_clause): Update call to cp_parser_omp_var_list.
(cp_parser_omp_clause_map): Add sk_omp scope around
cp_parser_omp_var_list_no_open call.
* parser.h (cp_parser): Add omp_array_section_p field.
* pt.cc (tsubst, tsubst_copy, tsubst_omp_clause_decl,
tsubst_copy_and_build): Add OMP_ARRAY_SECTION support.
* semantics.cc (handle_omp_array_sections_1, handle_omp_array_sections,
cp_oacc_check_attachments, finish_omp_clauses): Use OMP_ARRAY_SECTION
instead of TREE_LIST where appropriate.  Handle more types of map
expression.
* typeck.cc (build_omp_array_section): New function.

gcc/
* gimplify.cc (gimplify_expr): Ensure OMP_ARRAY_SECTION has been
processed out before gimplification.
* tree-pretty-print.cc (dump_generic_node): Support OMP_ARRAY_SECTION.
* tree.def (OMP_ARRAY_SECTION): New tree code.

gcc/testsuite/
* c-c++-common/gomp/map-6.c: Update expected output.
* c-c++-common/gomp/target-enter-data-1.c: Update scan test.
* g++.dg/gomp/array-section-1.C: New test.
* g++.dg/gomp/array-section-2.C: New test.
* g++.dg/gomp/bad-array-section-1.C: New test.
* g++.dg/gomp/bad-array-section-2.C: New test.
* g++.dg/gomp/bad-array-section-3.C: New test.
* g++.dg/gomp/bad-array-section-4.C: New test.
* g++.dg/gomp/bad-array-section-5.C: New test.
* g++.dg/gomp/bad-array-section-6.C: New test.
* g++.dg/gomp/bad-array-section-7.C: New test.
* g++.dg/gomp/bad-array-section-8.C: New test.
* g++.dg/gomp/bad-array-section-9.C: New test.
* g++.dg/gomp/bad-array-section-10.C: New test.
* g++.dg/gomp/bad-array-section-11.C: New test.
* g++.dg/gomp/has_device_addr-non-lvalue-1.C: New test.
* g++.dg/gomp/pr67522.C: Update expected output.
* g++.dg/gomp/ind-base-3.C: New test.
* g++.dg/gomp/map-assignment-1.C: New test.
* g++.dg/gomp/map-inc-1.C: New test.
* g++.dg/gomp/map-lvalue-ref-1.C: New test.
* g++.dg/gomp/map-ptrmem-1.C: New test.
* g++.dg/gomp/map-ptrmem-2.C: New test.
* g++.dg/gomp/map-static-cast-lvalue-1.C: New test.
* g++.dg/gomp/map-ternary-1.C: New test.
* g++.dg/gomp/member-array-2.C: New test.

libgomp/
* testsuite/libgomp.c++/baseptrs-4.C: Remove commented-out cases that
now work.
* testsuite/libgomp.c++/baseptrs-6.C: New test.
* testsuite/libgomp.c++/ind-base-1.C: New test.
* testsuite/libgomp.c++/ind-base-2.C: New test.
* testsuite/libgomp.c++/lvalue-tofrom-1.C: New test.
* testsuite/libgomp.c++/lvalue-tofrom-2.C: New test.
* testsuite/libgomp.c++/map-comma-1.C: New test.
* testsuite/libgomp.c++/map-rvalue-ref-1.C: New test.
* testsuite/libgomp.c++/struct-ref-1.C: New test.
* testsuite/libgomp.c-c++-common/array-field-1.c: New test.
* testsuite/libgomp.c-c++-common/array-of-struct-1.c: New test.
* testsuite/libgomp.c-c++-common/array-of-struct-2.c: New test.
52 files changed:
gcc/c-family/c-common.h
gcc/c-family/c-omp.cc
gcc/cp/constexpr.cc
gcc/cp/cp-tree.h
gcc/cp/decl2.cc
gcc/cp/error.cc
gcc/cp/parser.cc
gcc/cp/parser.h
gcc/cp/pt.cc
gcc/cp/semantics.cc
gcc/cp/typeck.cc
gcc/gimplify.cc
gcc/testsuite/c-c++-common/gomp/map-6.c
gcc/testsuite/c-c++-common/gomp/target-enter-data-1.c
gcc/testsuite/g++.dg/gomp/array-section-1.C [new file with mode: 0644]
gcc/testsuite/g++.dg/gomp/array-section-2.C [new file with mode: 0644]
gcc/testsuite/g++.dg/gomp/bad-array-section-1.C [new file with mode: 0644]
gcc/testsuite/g++.dg/gomp/bad-array-section-10.C [new file with mode: 0644]
gcc/testsuite/g++.dg/gomp/bad-array-section-11.C [new file with mode: 0644]
gcc/testsuite/g++.dg/gomp/bad-array-section-2.C [new file with mode: 0644]
gcc/testsuite/g++.dg/gomp/bad-array-section-3.C [new file with mode: 0644]
gcc/testsuite/g++.dg/gomp/bad-array-section-4.C [new file with mode: 0644]
gcc/testsuite/g++.dg/gomp/bad-array-section-5.C [new file with mode: 0644]
gcc/testsuite/g++.dg/gomp/bad-array-section-6.C [new file with mode: 0644]
gcc/testsuite/g++.dg/gomp/bad-array-section-7.C [new file with mode: 0644]
gcc/testsuite/g++.dg/gomp/bad-array-section-8.C [new file with mode: 0644]
gcc/testsuite/g++.dg/gomp/bad-array-section-9.C [new file with mode: 0644]
gcc/testsuite/g++.dg/gomp/has_device_addr-non-lvalue-1.C [new file with mode: 0644]
gcc/testsuite/g++.dg/gomp/ind-base-3.C [new file with mode: 0644]
gcc/testsuite/g++.dg/gomp/map-assignment-1.C [new file with mode: 0644]
gcc/testsuite/g++.dg/gomp/map-inc-1.C [new file with mode: 0644]
gcc/testsuite/g++.dg/gomp/map-lvalue-ref-1.C [new file with mode: 0644]
gcc/testsuite/g++.dg/gomp/map-ptrmem-1.C [new file with mode: 0644]
gcc/testsuite/g++.dg/gomp/map-ptrmem-2.C [new file with mode: 0644]
gcc/testsuite/g++.dg/gomp/map-static-cast-lvalue-1.C [new file with mode: 0644]
gcc/testsuite/g++.dg/gomp/map-ternary-1.C [new file with mode: 0644]
gcc/testsuite/g++.dg/gomp/member-array-2.C [new file with mode: 0644]
gcc/testsuite/g++.dg/gomp/pr67522.C
gcc/tree-pretty-print.cc
gcc/tree.def
libgomp/testsuite/libgomp.c++/baseptrs-4.C
libgomp/testsuite/libgomp.c++/baseptrs-6.C [new file with mode: 0644]
libgomp/testsuite/libgomp.c++/ind-base-1.C [new file with mode: 0644]
libgomp/testsuite/libgomp.c++/ind-base-2.C [new file with mode: 0644]
libgomp/testsuite/libgomp.c++/lvalue-tofrom-1.C [new file with mode: 0644]
libgomp/testsuite/libgomp.c++/lvalue-tofrom-2.C [new file with mode: 0644]
libgomp/testsuite/libgomp.c++/map-comma-1.C [new file with mode: 0644]
libgomp/testsuite/libgomp.c++/map-rvalue-ref-1.C [new file with mode: 0644]
libgomp/testsuite/libgomp.c++/struct-ref-1.C [new file with mode: 0644]
libgomp/testsuite/libgomp.c-c++-common/array-field-1.c [new file with mode: 0644]
libgomp/testsuite/libgomp.c-c++-common/array-of-struct-1.c [new file with mode: 0644]
libgomp/testsuite/libgomp.c-c++-common/array-of-struct-2.c [new file with mode: 0644]