aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp/parser.h
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2021-08-10 11:22:33 +0200
committerJakub Jelinek <jakub@redhat.com>2021-08-10 11:22:33 +0200
commitc40c6a50fd4da342c87a715ae83927a37797e094 (patch)
treea86711ef18c76c4e627b1a20fbe5b7a8cee20b6e /gcc/cp/parser.h
parentc318f8e42b3f90bed5a0648e42c0182a497566b7 (diff)
downloadgcc-c40c6a50fd4da342c87a715ae83927a37797e094.zip
gcc-c40c6a50fd4da342c87a715ae83927a37797e094.tar.gz
gcc-c40c6a50fd4da342c87a715ae83927a37797e094.tar.bz2
openmp: Add support for declare simd and declare variant in a attribute syntax
This patch adds support for declare simd and declare variant in attribute syntax. Either in attribute-specifier-seq at the start of declaration, in that case it has similar restriction to pragma-syntax, that there is a single function declaration/definition in the declaration, rather than variable declaration or more than one function declarations or mix of function and variable declarations. Or after the declarator id, in that case it applies just to the single function declaration and the same declaration can have multiple such attributes. Or both. Furthermore, cp_parser_statement has been adjusted so that it doesn't accept [[omp::directive (parallel)]] etc. before statements that don't take attributes at all, or where those attributes don't appertain to the statement but something else (e.g. to label, using directive, declaration, etc.). 2021-08-10 Jakub Jelinek <jakub@redhat.com> gcc/cp/ * parser.h (struct cp_omp_declare_simd_data): Remove in_omp_attribute_pragma and clauses members, add loc and attribs. (struct cp_oacc_routine_data): Remove loc member, add clauses member. * parser.c (cp_finalize_omp_declare_simd): New function. (cp_parser_handle_statement_omp_attributes): Mention in function comment the function is used also for attribute-declaration. (cp_parser_handle_directive_omp_attributes): New function. (cp_parser_statement): Don't call cp_parser_handle_statement_omp_attributes if statement doesn't have attribute-specifier-seq at the beginning at all or if if those attributes don't appertain to the statement. (cp_parser_simple_declaration): Call cp_parser_handle_directive_omp_attributes and cp_finalize_omp_declare_simd. (cp_parser_explicit_instantiation): Likewise. (cp_parser_init_declarator): Initialize prefix_attributes only after parsing declarators. (cp_parser_direct_declarator): Call cp_parser_handle_directive_omp_attributes and cp_finalize_omp_declare_simd. (cp_parser_member_declaration): Likewise. (cp_parser_single_declaration): Likewise. (cp_parser_omp_declare_simd): Don't initialize data.in_omp_attribute_pragma, instead initialize data.attribs[0] and data.attribs[1]. (cp_finish_omp_declare_variant): Remove in_omp_attribute_pragma argument, instead use parser->lexer->in_omp_attribute_pragma. (cp_parser_late_parsing_omp_declare_simd): Adjust cp_finish_omp_declare_variant caller. Handle attribute-syntax declare simd/variant. gcc/testsuite/ * g++.dg/gomp/attrs-1.C (bar): Add missing semicolon after [[omp::directive (threadprivate (t2))]]. Add tests with if/while/switch after parallel in attribute syntax. (corge): Add missing omp:: before directive. * g++.dg/gomp/attrs-2.C (bar): Add missing semicolon after [[omp::directive (threadprivate (t2))]]. * g++.dg/gomp/attrs-10.C: New test. * g++.dg/gomp/attrs-11.C: New test.
Diffstat (limited to 'gcc/cp/parser.h')
-rw-r--r--gcc/cp/parser.h7
1 files changed, 3 insertions, 4 deletions
diff --git a/gcc/cp/parser.h b/gcc/cp/parser.h
index e62742d..3669587 100644
--- a/gcc/cp/parser.h
+++ b/gcc/cp/parser.h
@@ -216,15 +216,14 @@ struct cp_omp_declare_simd_data {
bool error_seen; /* Set if error has been reported. */
bool fndecl_seen; /* Set if one fn decl/definition has been seen already. */
bool variant_p; /* Set for #pragma omp declare variant. */
- bool in_omp_attribute_pragma; /* True if declare simd/variant comes from
- C++11 attribute rather than pragma. */
+ location_t loc;
vec<cp_token_cache_ptr> tokens;
- tree clauses;
+ tree *attribs[2];
};
/* Helper data structure for parsing #pragma acc routine. */
struct cp_oacc_routine_data : cp_omp_declare_simd_data {
- location_t loc;
+ tree clauses;
};
/* The cp_parser structure represents the C++ parser. */