]> git.ipfire.org Git - thirdparty/gcc.git/commit
OpenMP: C++ support for metadirectives and dynamic selectors.
authorSandra Loosemore <sloosemore@baylibre.com>
Tue, 14 Jan 2025 23:28:02 +0000 (23:28 +0000)
committerSandra Loosemore <sloosemore@baylibre.com>
Thu, 16 Jan 2025 18:12:17 +0000 (18:12 +0000)
commit677e452e55e5a91e699d4f01cc9b88297cc41a0d
tree0679252841b0aa1379e9ac5435d4ebba0180ebfc
parent4e20914d3306d8898ce586313a40fb92ef0b8964
OpenMP: C++ support for metadirectives and dynamic selectors.

Additional shared C/C++ testcases are included in a subsequent patch in this
series.

gcc/cp/ChangeLog
PR middle-end/112779
PR middle-end/113904
* cp-tree.h (struct saved_scope): Add new field
x_processing_omp_trait_property_expr.
(processing_omp_trait_property_expr): New.
* parser.cc (cp_parser_skip_to_end_of_block_or_statement): Add
metadirective_p parameter and handle skipping over the parentheses
in a "for" statement.
(struct omp_metadirective_parse_data): New.
(mangle_metadirective_region_label): New.
(cp_parser_label_for_labeled_statement): Mangle label names in a
metadirective body.
(cp_parser_jump_statement): Likewise.
(cp_parser_omp_context_selector): Allow arbitrary expressions in
device_num and condition properties.
(cp_parser_omp_assumption_clauses): Handle C_OMP_DIR_META.
(analyze_metadirective_body): New.
(cp_parser_omp_metadirective): New.
(cp_parser_pragma): Handle PRAGMA_OMP_METADIRECTIVE.
* parser.h (struct cp_parser): Add omp_metadirective_state field.
* pt.cc (tsubst_omp_context_selector): New.
(tsubst_stmt): Handle OMP_METADIRECTIVE.
* semantics.cc (finish_id_expression_1): Don't diagnose use of
parameter outside function body in dynamic selector expressions here.

gcc/testsuite/
PR middle-end/112779
PR middle-end/113904
* c-c++-common/gomp/declare-variant-2.c: Adjust output for C++.
* g++.dg/gomp/declare-variant-class-1.C: New.
* g++.dg/gomp/declare-variant-class-2.C: New.
* g++.dg/gomp/metadirective-template-1.C: New.

libgomp/
PR middle-end/112779
PR middle-end/113904
* testsuite/libgomp.c++/metadirective-template-1.C: New.
* testsuite/libgomp.c++/metadirective-template-2.C: New.
* testsuite/libgomp.c++/metadirective-template-3.C: New.

Co-Authored-By: Kwok Cheung Yeung <kcy@codesourcery.com>
Co-Authored-By: Sandra Loosemore <sandra@codesourcery.com>
12 files changed:
gcc/cp/cp-tree.h
gcc/cp/parser.cc
gcc/cp/parser.h
gcc/cp/pt.cc
gcc/cp/semantics.cc
gcc/testsuite/c-c++-common/gomp/declare-variant-2.c
gcc/testsuite/g++.dg/gomp/declare-variant-class-1.C [new file with mode: 0644]
gcc/testsuite/g++.dg/gomp/declare-variant-class-2.C [new file with mode: 0644]
gcc/testsuite/g++.dg/gomp/metadirective-template-1.C [new file with mode: 0644]
libgomp/testsuite/libgomp.c++/metadirective-template-1.C [new file with mode: 0644]
libgomp/testsuite/libgomp.c++/metadirective-template-2.C [new file with mode: 0644]
libgomp/testsuite/libgomp.c++/metadirective-template-3.C [new file with mode: 0644]